gpt4 book ai didi

ios - Cocos2D pauseAllRunningActions?

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:50:15 25 4
gpt4 key购买 nike

我很难在我的 Cocos2D 应用程序中恢复动画。我将 CCSprite 作为子级添加到 CCSpriteBatchNode,它会播放动画。

所以当我点击暂停按钮时,我会这样做:

[[[CCDirector sharedDirector] actionManager] pauseAllRunningActions];

现在在他们说要使用的文档中:

[[[CCDirector sharedDirector] actionManager] resumeTargets:];

但是,我已经尝试了所有可能的目标,包括 Sprite 本身、batchnode、self (CCLayer) 和当前的 CCScene,但没有任何效果。

是否有某种方法可以恢复所有目标?

编辑:我在 Singleton 中声明了一个 NSSet 并且我这样做了:

[Singleton sharedSingleton].pauseTargets = [[[CCDirector sharedDirector] actionManager] pauseAllRunningActions];
[[[CCDirector sharedDirector] actionManager] pauseAllRunningActions];

然后我继续:

[[[CCDirector sharedDirector] actionManager] resumeTargets:[Singleton sharedSingleton].pauseTargets];

但是我崩溃了:

2012-08-29 18:40:05.433 App[34872:707] -[__NSMallocBlock__ countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x1e075a40
2012-08-29 18:40:05.434 App[34872:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSMallocBlock__ countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x1e075a40'

最佳答案

存储暂停的目标

NSSet *pausedTargets = [[NSSet alloc] initWithSet:[[[CCDirector sharedDirector] actionManager] pauseAllRunningActions]];

恢复暂停的目标

[[[CCDirector sharedDirector] actionManager] resumeTargets:pausedTargets];

此外,不要忘记在取消暂停后释放 pausedTargets

关于ios - Cocos2D pauseAllRunningActions?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12187129/

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