2009-11-26 3 views

답변

2

을 저를 도와주세요이

여전히 새로운입니다. 다음은 link to the Timer class overview - cocos2d for iPhone 0.8.2입니다. 직접 (그러나 간접적으로) 구현할 필요는 없지만 그것이 어떻게 작동하는지 알면 좋습니다.

cocos2d를 사용하여 실제 카운터를 화면에 표시하려면 LabelAtlas을보십시오. 여기에 link to LabelAtlas class overview - cocos2d for iPhone 0.8.2

/* basically you create a LabelAtlas subclass that 
    has a method for updating itself with the current time 
    or score. I will call it ScoreLabel in this example */ 
ScoreLabel * bonusScore = [[ScoreLabel alloc] initWithString:@"0" 
               charMapFile:@"charMap.png" 
               itemWidth:10 
               itemHeight:10 
               startCharMap:'0']; 
// then schedule a method to be called that updates the current score 
// schedule: paramter of type SEL. It should pass the method to be scheduled 
// interval is in seconds, it determines how often the method is called. 
[bonusScore schedule:@selector(updateScore) interval:0.5]; 

/* the implementation of the updateScore method could be */ 
-(void)updateScore { 
    [self setString: [[World sharedWorld] timeLeft]]]; 
} 

당신이 클래스를 지원하는 데 필요한 이미지를 구현하는 방법을 볼 수있는 AtlasSprites의적인 Cocos2D의 예에서 보면 (그리고 LabelAtlas에 대한)를 가지고있다.