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