cocos2d 0.99 与cocos2d v2.1 restoreOriginalFrame 播放动画使用重置默认桢的区别

前端之家收集整理的这篇文章主要介绍了cocos2d 0.99 与cocos2d v2.1 restoreOriginalFrame 播放动画使用重置默认桢的区别前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

// 创建一个英雄

CCSprite *heroSprite = [CCSprite spriteWithSpriteFrameName:@"Hero-Default.png"];

heroSprite.position = ccp(200,200);

[self addChild:heroSprite];

// 为英雄收集翅膀

NSMutableArray*animationFrames = [NSMutableArrayarrayWithCapacity:2];

for(inti =1; i <5; i++) {

NSString*fileName = [NSStringstringWithFormat:@"Hero-Fly-%d.png",i];

CCSpriteFrame*frame = [[CCSpriteFrameCachesharedSpriteFrameCache]spriteFrameByName:fileName];

[animationFramesaddObject:frame];

}

// 为英雄插入翅膀,开始飞行 v0.99

CCAnimation *animation = [CCAnimation animationWithFrames:animationFrames delay:0.2f];

CCAnimate *animate = [CCAnimate actionWithAnimation:animation restoreOriginalFrame:NO];

[heroSprite runAction:animate];


//为英雄插入翅膀,开始飞行 v2.1

CCAnimation *animation = [CCAnimation animationWithSpriteFrames:animationFrames delay:delay];

animation.restoreOriginalFrame = NO;

CCAnimate *animate = [CCAnimate actionWithAnimation:animation];

return animate;


ps:供大家可作参考,有什么问题可以直接评论或发邮件

猜你在找的Cocos2d-x相关文章