Hello everyone !
How to make the end of animation the sprite’s image is the first frame or the specified image.In other words, how to change the image of a sprite that has been created. 
Thanks.
If you use spritesheet animation and you want to make sure that the end of animation is the correct image frame, you should add the image frame as the last SpriteFrame entry in the vector. Alternatively you could use CCSequence and add CCCallfunc that call a function to force load the sprite’s texture using setTexture or loadTexture function (depends on the class).
@wiwing
Yes, I use spritesheet animation,but animation is the loop.
Animation is always played. When a certain condition, the animation will stop. Then the animation will stay in a certain frame, but I want it to return to the beginning of the state.
I can’t use English freely and I hope you can understand what I mean.
maybe you should create something like this:
create sequence that run these actions animate spritesheet -> call function to handle complete animation callback (if no callback just do nothing) then repeat the sequence
but that can only work if the animation already completed till the last frame, it can’t handle something when you stop the animation that is still playing
Use anim->setRestoreOriginalFrame(true);
@smitpatel88
Thank you very much!!! This is what I want!
Also thanks @wiwing!!
But when it is loop, setRestoreOriginalFrame will fail.
Hey,man! I found a way! look at this code:
auto body = Sprite::create("XXX.png");
SpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("XXX.plist");
auto frame = SpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("XXXXX.png");
body->setDisplayFrame(frame);
Use The SetTexture method to change the image at RunTime.
Thanks, I’ve already solved the problem