0
我使用spriteKit爲我的比賽,我發現一個水龍頭和雙擊使用下面的代碼:雪碧套件雙擊檢測
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch* touch = [touches anyObject];
if (touch.tapCount == 1){
[self.tapQueue addObject:@1];
NSLog(@"touch.tapCount == 1 :)");
}
if (touch.tapCount == 2) {
[self.tapQueue addObject:@2];
NSLog(@"touch.tapCount == 2 :)");
}
}
-(void)processUserTapsForUpdate:(NSTimeInterval)currentTime {
for (NSNumber* tapCount in [self.tapQueue copy]) {
if ([tapCount unsignedIntegerValue] == 1)
[self singleTap];
if ([tapCount unsignedIntegerValue] == 2)
[self doubleTap];
[self.tapQueue removeObject:tapCount];
}
}
該代碼檢測單一的水龍頭但是當它檢測到雙擊它檢測單擊它。我如何區別單擊和雙擊?
感謝
要麼使用雙擊手勢識別器,要麼觸摸開始等待另一次觸摸,然後在足夠長的時間(即0.3秒)內運行單擊代碼之前沒有任何連續的敲擊 – LearnCocos2D 2014-10-28 10:16:48
@ LearnCocos2D感謝您的幫助:) – Mariam 2014-10-28 19:39:17