3

我很难在我的 Cocos2D 应用程序中恢复动画。我将一个 CCSprite 作为一个子项添加到一个 CCSpriteBatchNode 中,它会在动画中消失。

因此,当我单击暂停按钮时,我会这样做:

[[[CCDirector sharedDirector] actionManager] pauseAllRunningActions];

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

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

但是,我已经尝试了所有可能的目标,包括精灵本身、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'
4

1 回答 1

4

存储暂停的目标

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

恢复暂停的目标

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

也不要忘记pausedTargets在取消暂停后释放。

于 2012-08-29T23:10:21.540 回答