2014-11-01 90 views
0

表明但是这个代码只显示我的序列的第一个图像,请帮我修改这个代码工作动画从我要让动画从PNG序列显示PNG序列的Xcode

这是代码:

CCSprite *character= [CCSprite spriteWithFile:[NSString stringWithFormat:@"1-enable001.png"]]; 

character.position = ccp(240*g_fx, 151*g_fy); 
[characterList addObject:character]; 
[self addChild:character ]; 

回答

0
CCSprite *character = [[CCSprite alloc] init];//Create sprite 

anim = [[CCAnimation animation] retain];//Create animation 
[anim addFrameWithFilename:@"1-enable001.png"];//Animation1.png 
[anim addFrameWithFilename:@"1-enable002.png"];//Animation2.png 
[anim addFrameWithFilename:@"1-enable003.png"];//Animation3.png 
id animateAction = [CCAnimate actionWithDuration:2.0f animation:anim restoreOriginalFrame:NO]; 

[sprite runAction:animateAction];//Run animation