我在Cocos2d iPhone游戏中使用CCSpeed行动。但是一直崩溃。Cocos2d CCSpeed在行动崩溃
CCAnimation* animation = nil;
animation = [[CCAnimationCache sharedAnimationCache] animationByName:ATTACK_ANIM];
if(animation)
{
CCAnimate *animAction = [CCAnimate actionWithAnimation:animation];
id speed = [CCSpeed actionWithAction:animAction speed:0.13f];
id calBlock = [CCCallBlock actionWithBlock:^{
//[self updateState:kTileState_Idle];
}];
CCSequence *sequence = [CCSequence actions:speed, calBlock, nil];
[self runAction:sequence];
}
但下面的代码工作正常..但无法更改动画速度。上面的代码有什么问题?
CCAnimation* animation = nil;
animation = [[CCAnimationCache sharedAnimationCache] animationByName:quakeAnim];
if(animation)
{
CCAnimate *animAction = [CCAnimate actionWithAnimation:animation];
id calBlock = [CCCallBlock actionWithBlock:^{
//[self updateState:kTileState_Idle];
}];
CCSequence *sequence = [CCSequence actions:animAction, calBlock, nil];
[self runAction:sequence];
}
这里是一个花药thread。但没有提供代码解决方案。
加载后我们无法更改delayPerUnit。我需要随着游戏进程动态改变动画速度。 – Guru 2013-03-06 16:19:29
该属性不是只读的,所以你可以在游戏中改变它。如果您担心并发(多个实例),请复制缓存的动画并更改副本上的delayPerUnit,然后运行副本。 – YvesLeBorg 2013-03-06 16:23:09
其工作..感谢您的信息。 – Guru 2013-03-06 16:55:34