0
我想添加一個計時器到我的遊戲。我有一個GameManager單例。Cocos2d遊戲定時器
-(void) startTimerWithDuration:(float) duration
{
[self schedule:@selector(timeUp) interval: duration];
}
-(void) timerUp
{
[self unschedule:_cmd];
[self lose];
}
-(void) lose
{
[[CCDirector sharedDirector] pushScene: [GameOverScene node]];
}
然後在我的GameScene初始化,我有
[self addChild:[GameManager node]];
然後,我有:
[[GameManager sharedManager] startTimerWithDuration:60.0f];
我得到這個錯誤控制檯:
*** Assertion failure in -[CCTimer initWithTarget:selector:interval:
這是cctimer
#if COCOS2D_DEBUG
NSMethodSignature *sig = [t methodSignatureForSelector:s];
NSAssert(sig !=0 , @"Signature not found for selector - does it have the following form? -(void) name: (ccTime) dt");
#endif
我不知道爲什麼。有沒有一些常用的方法來計算時間?由於這是我猜的常見用法。
你想安排什麼方法? – Andrew 2011-03-19 08:31:03
是的,錯別字。 – John 2011-03-19 19:29:18