Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of Heirarchy #2

Closed
ryanprice opened this issue Jan 27, 2010 · 1 comment
Closed

Usage of Heirarchy #2

ryanprice opened this issue Jan 27, 2010 · 1 comment

Comments

@ryanprice
Copy link

I have a question about the recommended use of the hierarchy.

I use the SM.state property to do alot of conditional evaluation. i.e: if(SM.state == "active")

I would like to have say 2 states , "dying" and "dead". If I was to check this
if(SM.state == "dead") , is there a way that I could have that condition also = "dying" ?

I thought maybe if dead was the parent state and dying was the child, but that doesn't work

do I need to do if(state == "dying" || state == "dead") everytime ? that doesn't feel right to me.

Or should I have 3 states "deadAsParent" as the parent, and "dying" and "dead' as the child
and then only ever test (SM.parentState == "deadAsParent")

I may be overcomplicating this, as I am still grasping how to use this class in real-world cases.

Thanks again
Ryan

@ryanprice
Copy link
Author

ahh I see you can't do this anyways (SM.parentState == "deadAsParent")

So i guess my question now is, if I go to a child state, does it play the enter: of the parent AND of the child ?

     monsterSM.addState("melee attack",{parent:"atack", enter:onMeleeAttack, from:"attack"})
     monsterSM.addState("smash",{parent:"melle attack", enter:onSmash})

does onMeleeAttack and onSmash get run ?
What are some of the benefits of using the hierarchy ?

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant