问题
I have been building a SpriteKit game for a while now. Its a card game that allows double-tap on card sprites for specific behaviors. Now that we're in iOS 9, double taps do not work at all on iPhone 6s. Works fine on iOS8, all devices.
In my SKScene
, i'm using the touchesBegan
method to detect taps:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInNode:self];
if(touch.tapCount==2) {
NSLog(@"double-tap, but not for iPhone 6s");
}
}
Is there anything new with iOS9 or the 6s specifically (3d touch?) that needs to be implemented now for SpriteKit games?
I would like to note that this works fine in the iPhone 6s simulator, but it does not on the actual device.
Also, touch.tapCount
will report 3, 4, 5, 6, 7 etc. taps, but completely skips just the second tap.
回答1:
According to https://developer.apple.com/library/prerelease/ios/releasenotes/General/RN-iOSSDK-9.1/
UIKit
Note
On 3D Touch capable devices, touch pressure changes cause
touchesMoved:withEvent: to be called for all apps running on iOS 9.0.
When running iOS 9.1, the method is called only for apps
linked with the iOS 9.0 (or later) SDK.
Apps should be prepared to receive touch move events
with no change in the x/y coordinates.
So if this problem can be caused by touchMoved.
回答2:
Ok, so, double taps ARE working, sort of. On iPhone 6s, the game, though reporting 60 fps through skView.showsFPS = YES;
, is running very laggish. I just discovered that I can get the taps to work if I tap slowly, as in wait one whole second between the first and second tap.
Now onto discovering why this game is so slow on this device. Its not even an iOS 9 issue because the game works just fine on my 5s w/ iOS 9.
来源:https://stackoverflow.com/questions/33042801/ios-9-spritekit-double-tap-not-working-on-iphone-6s