Cocos2d animation from sprite sheet
So i have the action build to make my frog jump but i have 5 images and i want to run them in the order 1,2,3,4,5,4,3,2,1 using the coordin开发者_如何学Pythonates. I only want to loop them once everytime the from jumps.
Thanks
while defining your image you can use the following code:
CCAnimation* anim = [CCAnimation animationWithName:@"frog"];
CCSpriteFrame* frames[5];
CGRect Rect;
// some code to initialize Rect position
for(int i=0;i<5;i++)
{
frames[i] = [CCSpriteFrame frameWithTexture:@"frog.png" rect:Rect];
// some code to move Rect so that it will mark next frame;
}
for(int i=0;i<5;i++)
[anim addFrame:frames[i]];
for(int i=3;i>=0;i--)
[anim addFrame:frames[i]];
use ccanimation and ccspritebatchnodefile
save your image sequence in spritesheet
精彩评论