Fork me on GitHub

使用 CCSpriteFrameCache 动画的实现

转载地址:http://blog.csdn.net/ssihc0/article/details/6784819

   CCSpriteFrameCache *cache = [CCSpriteFrameCache sharedSpriteFrameCache];
[cache addSpriteFramesWithFile:@"t1.plist" textureFile:@"t1.png"];

CCSprite *mySprite = [CCSprite spriteWithSpriteFrameName:@"a1.png"];
mySprite.position = ccp(240,160);
[self addChild:mySprite];


NSMutableArray *climbFrames = [NSMutableArray array];
for(int i = 1; i < 7; i++) {
NSString *fn = [NSString stringWithFormat:@"a%d.png",i];
CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:fn];
[climbFrames addObject:frame];
}

CCAnimation *animateClimb = [CCAnimation animationWithFrames:climbFrames delay:0.2f];
id a1 = [CCAnimate actionWithAnimation:animateClimb restoreOriginalFrame:NO];
[mySprite runAction:a1];



posted on 2012-04-06 17:46  pengyingh  阅读(863)  评论(0)    收藏  举报

导航