2011-03-18 1 views
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 

理由はわかりません。時間を数えるための共通のアプローチがありますか?それは一般的な使い方なので、私は推測します。

+0

すべきですか? – Andrew

+0

ええ、そこにタイプミス。 – John

答えて

0

あなた

-(void) timerUp 
{ 
    [self unschedule:_cmd]; 
    [self lose]; 
} 

をスケジュールするんどの方法

-(void) timerUp:(ccTime)delta 
{ 
    [self unschedule:_cmd]; 
    [self lose]; 
}