Objective c Cocos2d游戏计时器
我想给我的游戏添加一个计时器。我有一个游戏经理Objective c Cocos2d游戏计时器,objective-c,timer,count,cocos2d-iphone,Objective C,Timer,Count,Cocos2d Iphone,我想给我的游戏添加一个计时器。我有一个游戏经理 -(void) startTimerWithDuration:(float) duration { [self schedule:@selector(timeUp) interval: duration]; } -(void) timerUp { [self unschedule:_cmd]; [self lose]; } -(void) lose { [[CCDirector sharedDirector] pus
-(void) startTimerWithDuration:(float) duration
{
[self schedule:@selector(timeUp) interval: duration];
}
-(void) timerUp
{
[self unschedule:_cmd];
[self lose];
}
-(void) lose
{
[[CCDirector sharedDirector] pushScene: [GameOverScene node]];
}
然后在我的游戏场景初始化中,我有
[self addChild:[GameManager node]];
那么我有:
[[GameManager sharedManager] startTimerWithDuration:60.0f];
我在控制台中遇到此错误:
*** Assertion failure in -[CCTimer initWithTarget:selector:interval:
这是计时器
#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
我不知道为什么。是否有一些常用的方法来计算时间?我想这是一种常见的用法。你的
-(void) timerUp
{
[self unschedule:_cmd];
[self lose];
}
应该是
-(void) timerUp:(ccTime)delta
{
[self unschedule:_cmd];
[self lose];
}
您想安排什么方法?