2014-11-01 61 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