0
votes

i want to change a sprite texture dynamically within animation.here is my code..

smileTexture=[[CCTextureCache sharedTextureCache] addImage:@"Monkey-smile_pad.png"];
angryTexture=[[CCTextureCache sharedTextureCache] addImage:@"Monkey-angry_pad.png"];

and to change the texture of sprite _monkeyone i do this..

_monkeyOne.texture=smileTexture;

and it change the sprite texture successfully.....but it's instant....i want this change within animation duration.....

can anyone help me...??

2

2 Answers

0
votes

I don't know of a way to do what you are asking right off, but to "cheat" you could make a new sprite directly on top of the old sprite and have the new sprite contain the old texture. Change the underlying texture. Then fade out the top sprite (and remove it) when finished.

0
votes

Check the cocos2d sprite tests. You will find examples of how to animate your sprites in there.