0

所以,我在 cocos2d 框架上写了一个游戏。我有一枚火箭飞过太空,当按下暂停按钮时,我需要停止一切。正因为如此,我在基GameObject类中做了一个观察者,它说:

[[Game sharedGame] addObserver:self forKeyPath:@"isPaused" options:0 context:nil];

init方法和

[[Game sharedGame] removeObserver:self forKeyPath:@"isPaused"];

dealloc方法中

Cannot remove an observer <Rocket 0xa3a1c10> for the key path "isPaused" from <Game 0x94a7cc0> because it is not registered as an observer. 所以,当我尝试重新启动场景时,我收到一条错误消息。如果我用 try catch 尝试这个,它不会调用异常但仍然无法正常工作,给我一条消息

An instance 0xb1d3380 of class Game was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info: <NSKeyValueObservationInfo 0x13c6fa20> ( <NSKeyValueObservance 0xb1b6740: Observer: 0xb120ce0, Key path: isPaused, Options: <New: NO, Old: NO, Prior: NO> Context: 0x0, Property: 0xb1171a0> 和废话废话

我应该怎么办?

问候。

4

0 回答 0