【发布时间】:2014-06-16 03:45:26
【问题描述】:
我已经知道如何在单视图应用程序中制作计时器,但不是 Spritekit。当我使用以下代码时,出现 2 个错误(如下所列)。谁能帮我解决这个问题?谢谢,杰克。
计时器。
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!见:stackoverflow.com/a/23978854/201863
标签: ios objective-c sprite-kit nstimer