我想出瞭如何在單視圖應用程序中創建定時器,但不是Spritekit。當我使用下面的代碼時,我得到2個錯誤(下面列出)。任何人都可以幫我解決這個問題嗎?謝謝,傑克。如何在Spritekit中創建一個計時器?
計時器。
if(!_scorelabel) {
_scorelabel = [SKLabelNode labelNodeWithFontNamed:@"Courier-Bold"];
_scorelabel.fontSize = 200;
_scorelabel.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
_scorelabel.fontColor = [SKColor colorWithHue: 0 saturation: 0 brightness: 1 alpha: .5];
[self addChild:_scorelabel];
}
_scorelabel = [NSTimer scheduledTimerWithTimeInterval: 1 target:self selector:@selector(Timercount)userInfo: nil repeats: YES];
的錯誤
Incompatible pointer types assigned to 'SKLabelNode*' from 'NSTimer*'
Undeclared selector 'Timercount'
不使用NSTimer!請參閱:http://stackoverflow.com/a/23978854/201863 – LearnCocos2D