0
所以我试图在我的项目中加入一个定时器,它会逐渐减少。例如,一个3秒钟的计时器在3秒钟后最终会变为0。我问这个问题,这个问题之前,我有一个关于使用NSTimeInterval
的反应,这就是我把它架在我的代码:Spritekit中的定时器和目标C
@implementation MyScene {
NSTimeInterval _timestamp;
}
定时器开始:
_timestamp = [NSDate timeIntervalSinceReferenceDate];
Check your timer in your update pass:
- (void)update:(NSTimeInterval)currentTime {
if(_timestamp != nil && currentTime - _timestamp.timeIntervalSinceReferenceDate >= 3.0) {
// Perform your timer event
}
// Other updates
}
然而这使我对在更新的第一行一对夫妇的错误:这些错误是:
member reference base type 'NSTimeInterval' (aka 'double') is not a structure or union
Invalid operands to binary expression ('NSTimeInterval' (aka 'double') and 'void)
感谢麦迪,我敢肯定,我看你无处不在:d – user2876115