Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
How do you code for animation sequences ? Say i want at some gamestate to do: Attack1 "and when that animation is finished" Kick2 "and when that animation is finished" Attack2 "and when that animation is finished" Runaway And then game state ends and transitions to some thing else My animations get broken off as the new one comes in |
||||
|
There are many ways of doing it in CC, if you are using the preview build then you can utilize the new API. you can use the code ccbGetCurrentAnimationFrame(animatednode)to check if the current animation frame of the animated scenenode is equal to the last frame of your animation. For example if your animation has frames from 0-48, then you can check if the command returning the frame number = 48, then play another animation then do the same thing for other animations. |
||||
|
Hi DouweDabbe, Currently, I'm using states for such cases. I.e. you have a behavior property or just a variable which represents different states: var STATE_WAIT_FOR_ACTION_TO_COMPLETE = 'waitForActionToComplete'; I also define a current state variable and assign the default state: var curState = STATE_INIT; Then inside onAnimate function I put a switch like: switch(curState): Also not that setTimeout function does not exist if you build for desktop, so you have to use a polyfill for that. This approach is basically a simple state machine. I also find it very useful for coding things like AI or weapon switch/attack/reload logic. |
||||
|
Thank you all ! Very usefull tips here |
|