0
我正在使用Cocos2d引擎,并且遇到了一个奇怪的问题。多个Sprite操作
我有一个精灵。此外,我有2个动画的精灵。我想在应用程序加载时播放一个动画,在调用ccTouchevent之后播放一个动画。
walkAnim = [CCAnimation animation];
dropAnim = [CCAnimation animation];
for(int q=1;q<12;q++){
[walkAnim addFrameWithFilename: [NSString stringWithFormat:@"walkforward_%.2d.png", q]];
[dropAnim addFrameWithFilename: [NSString stringWithFormat:@"drop_%.2d.png", q]];
}
action = [CCAnimate actionWithAnimation:walkAnim];
action.duration = 2;
id act = [CCRepeatForever actionWithAction:action];
[sprite runAction:act];
所以,在这里我们看到一个动画精灵。
[sprite stopAllActions]; //and here my torture begins
我试图创建一个行动的许多方面:
我试图添加其他AnimateAction,试图替换当前的动画,但在发生碰撞的一切结果。
[action setAnimation:dropAnim];
和
CCAnimate* animat = [[CCAnimate alloc]initWithDuration:30 animation:dropAnim restoreOriginalFrame:YES];
和
id action = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:dropAnim]];
[player1 runAction:action];
崩溃是[CCAnimate actionWithAnimation:]
+(id) actionWithAnimation: (CCAnimation*)anim
{
return [[[self alloc] initWithAnimation:anim restoreOriginalFrame:YES] autorelease];
}
谢谢!
要从另一种方法启动一个动作,您必须保留动作
例如:[action retain];
,如果你发现你的问题,请在这里回答自己和接受它的答案,所以其他的可以的情况下,使用它,他们发现这个职位。祝你好运! – 2011-03-30 10:11:51
请注意“并接受它”部分,URLArenzo。另外,请仔细考虑您的标签。这与Xcode 4完全没有关系 - 这是一种语言/ API问题。 – 2011-03-30 11:33:45
谢谢,明天我将能够接受。 – 0xDE4E15B 2011-03-30 11:36:07