【发布时间】:2013-03-19 07:06:01
【问题描述】:
代码::
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] 但是,它对我不起作用,一旦开始它就不会暂停。
【问题讨论】:
标签: iphone animation cocos2d-iphone