开发者

Cocos2d animation from sprite sheet

开发者 https://www.devze.com 2023-02-22 01:44 出处:网络
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 everyt

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

0

精彩评论

暂无评论...
验证码 换一张
取 消