Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c Cocos2d游戏计时器_Objective C_Timer_Count_Cocos2d Iphone - Fatal编程技术网

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];
}

您想安排什么方法?