gpt4 book ai didi

ios - Cocos2d : are there any possible run time errors if two sprites run the same CCAnimation from CCAnimationCache at the same time?

转载 作者:行者123 更新时间:2023-11-29 04:14:36 25 4
gpt4 key购买 nike

不确定问题是否清楚,但我发现了这一点,并且想知道每次特定 Sprite 必须爆炸时调用的 runExplosionAnimation 方法是否会发生任何冲突。在我正在开发的游戏中,屏幕上可以有 20 个这样的 Sprite ,我想知道是否可以让它们共享相同的动画(请参阅 animationByName:@"anAnimation")或如果两个 Sprite 同时爆炸,这可能会导致一些运行时错误。

-(void) runExplosionAnimation
{
[self stopAllActions];

CCAnimation* anim = [[CCAnimationCache sharedAnimationCache] animationByName:@"anAnimation"];
if(anim!=nil){
[self runAction:[CCSequence actions: [CCAnimate actionWithDuration:0.4f animation:anim restoreOriginalFrame:false], [CCHide action], nil]];
}
else{
[self loadSharedAnimationIfNeeded];
}

}

最佳答案

我尚未遇到问题,但可能的同时目标数少于 20 个。然而,阅读 cocos2d (2.0) 代码,CCAnimation 对象几乎是一个 POCO(普通 Objective-C 对象:)):它似乎不维护任何类型的状态。 CCAnimate 就是这么做的。因此,这些对象几乎是“只读”的,在放入缓存后不太可能发生更改,而且我看不到会导致该类的任何 getter 方法出现问题的条件。我对此感到安全,在使用线程模型时极不可能发生这种情况。

关于ios - Cocos2d : are there any possible run time errors if two sprites run the same CCAnimation from CCAnimationCache at the same time?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13902354/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com