所以在我的遊戲中,我想通過幀動畫來創建一個簡單的幀。當我在init函數中使用它時,動畫工作正常,但是一旦我停止動作並嘗試重新啓動它,什麼都不會發生。運行動作失敗
這是在init
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:
@"Dubstep Dan_default.plist"];
CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode
batchNodeWithFile:@"Dubstep Dan_default.png"];
[self addChild:spriteSheet];
walkAnimFrames = [NSMutableArray array];
for(int i = 1; i <= 8; ++i) {
[walkAnimFrames addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:@"1-%d.png", i]]];
}
walkAnim = [CCAnimation animationWithFrames:walkAnimFrames delay:0.1f];
self.character = [CCSprite spriteWithSpriteFrameName:@"1-1.png"];
_character.position = ccp(80, 260);
self.walkAction = [CCRepeatForever actionWithAction:
[CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
// self.walkAction = [CCAnimate actionWithAnimation:walkAnim];
[_character runAction:_walkAction];
[_walkAction retain];
[spriteSheet addChild:_character];
,這是在我的遊戲蜱功能
if(gp.isControlling && (gp.controlQuadrant == 0 || gp.controlQuadrant == 1) && (_character.position.x < 250))
{
if([_walkAction isDone]) {
[_character runAction:_walkAction];
NSLog(@"TEST");
}
targetX = 7;
_character.scale = 1;
}
else {
[_character stopAction:_walkAction];
targetX = 0;
你斷點調試此問題解決了,看你甚至進入「如果(GP。......」的條款? – YvesLeBorg 2013-03-19 18:42:02
它確實是因爲當我使用操縱桿時,角色右移 – user1569940 2013-03-19 18:42:47
我應該重複我的問題嗎 – YvesLeBorg 2013-03-19 18:44:00