나는 cocos2d에서 카운트 다운 타이머를 만들려고 노력하고 있지만이 문제를 해결하고 싶습니다. 내 코드가이 아래에 있습니다. 아마 논리가 잘못되었지만 수정할 수 없습니다.cocos2d의 카운트 다운 타이머?
-(id) init
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super" return value
if((self=[super init])) {
CCSprite *background = [CCSprite spriteWithFile:@"backgame.png"];
CGSize size = [[CCDirector sharedDirector] winSize];
[background setPosition:ccp(size.width/2, size.height/2)];
[self addChild: background];
[self schedule:@selector(countDown:)];
}
return self;
}
-(void)countDown:(ccTime)delta
{
CCLabel *text = [CCLabel labelWithString:@" "
fontName:@"BallsoOnTheRampage" fontSize:46];
text.position = ccp(160,455);
text.color = ccYELLOW;
[self addChild:text];
int countTime = 20;
while (countTime != 0) {
countTime -= 1;
[text setString:[NSString stringWithFormat:@"%i", countTime]];
}
}
Zebulon이 답장을 보내 주신 데 대해 감사 드리며 그 코드와 설명이 오늘 당일 원했고 도움을 많이 주신 방식대로 작동하고 있습니다. 지금 많은 것을 배웠습니다. – gangmobile
@gangmobile, 허용 된대로 내 대답을 확인할 수 있음을 잊지 마십시오. : D –