代碼::如何在cocos2d-iphone的一段時間後停止動畫?
if (CGRectIntersectsRect(food.sprite.boundingBox, playerRect)) {
[food.sprite stopAllActions];
[walkAnimFrames addObject: [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:@"newpackman2.png", 0]]];
[walkAnimFrames addObject: [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:@"newpackman3.png", 1]]];
walkAnim = [CCAnimation animationWithFrames:walkAnimFrames delay:0.2f];
self.walkAction = [CCRepeatForever actionWithAction: [CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
self.walkAction.tag = 1;
[chef runAction:_walkAction];
}
它正常工作,它當物體相撞的廚師,但連續運行啓動動畫。
我想在3-4秒後停止動畫。
我已經使用[sprite stopActionByTag:1]
但是,它不適用於我,一旦它啓動它不會暫停。
哇,,它就像一個魅力但它停止了我的其他行動,如[廚師runAction:[CCRepeatForever actionWithAction: [CCSequence操作: [CCMoveBy actionWit hDuration:1.0 position:ccp(0,240)], [CCMoveBy actionWithDuration:1.0 position:ccp(0,-240)],nil]]];我想在我的動畫停止後繼續這個動作。 – 2013-03-19 07:22:22
我記得我遇到了一些阻止問題。比你不需要停止所有的行動。嘗試爲所有動畫設置標籤CCMoveBy,CCMoveBy,CCSequence,CCRepeatForever。並在此塊中使用標籤來阻止它們。 – 2013-03-19 07:27:51
啊,它工作正常......謝謝!我想投票但沒有足夠的聲望.. – 2013-03-19 07:34:51