[SOLVED][Animation] Doesn't go back to original frame

Hi,

I have a problem on my Animation, it doesn’t go back to its original frame after the animation is done/interrupted.

I have obj which is a laser beam. It has its animation which it should glow.
obj->runAction(glow);

When obj collides with an enemy ship. I do obj->stopAllActions(); and set it invisible.

My problem is that when obj is spawn again, it shows a frame of animation glow, not its original frame.

What should I do? do i have to setDisplayframe(with_the_orig_frame) before it spawn?

1 Like

I had same issue. Removing the action or all actions from the target if you do not need to worry about other actions or also setting the display frame worked for me.

For removing action I used set tag on action then used action manager to remove action by tag.

You have to tell the animation, that you want the original frame to be restored:

void setRestoreOriginalFrame( bool restoreOriginalFrame )	
Sets whether to restore the original frame when animation finishes.

I tried that too. But will it sill work if the animation is interrupted? Because as what I’ve notice it doesn’t. Ex. if an animation is still going on and the you suddenly stopAllActions()

It only works, if the animation can finish, as the method description suggests. If you interrupt the animation, it is your responsibility to change the state. You could use a callback for that.

ok thanks.