iOS 9 SpriteKit 在 iPhone 6S 上双击无法正常工作

4

我已经在制作一个SpriteKit游戏一段时间了。它是一款纸牌游戏,允许双击卡片图像进行特定行为。现在我们已经到了iOS 9版本,在iPhone 6s上双击根本不起作用。在iOS8上和所有设备上都可以正常运行。

在我的SKScene中,我使用touchesBegan方法检测点击:

-(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");
    }
}

iOS9或6s有什么新功能(3D Touch)需要现在为SpriteKit游戏进行实现吗?

我想指出,在iPhone 6s模拟器上这很好用,但在实际设备上不行。

此外,touch.tapCount将报告3、4、5、6、7等点击数,但完全跳过第二次点击。


我刚刚更新了我的问题并提供了另一个信息。第三、第四、第五个选项卡等被检测到了,只是第二个没有被特别检测到。 - Matt Fiocca
@EpicByte,我刚刚发布了我的答案。它能运行,但并不像你预期的那样。 - Matt Fiocca
2个回答

1

好的,双击功能确实是有效的,但有点问题。在iPhone 6s上,游戏虽然通过skView.showsFPS = YES;报告60 fps,但运行非常卡顿。我刚刚发现,如果我慢慢轻敲屏幕,也就是在第一次和第二次轻敲之间等待一整秒,我可以使双击功能正常工作。

现在我们要找出为什么这个游戏在这个设备上运行如此缓慢。这甚至不是iOS 9的问题,因为这个游戏在我使用iOS 9的5s上完全正常。


1

根据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.

所以如果这个问题是由 touchMoved 引起的。

这是实际正确的答案。谢谢!在touchesBegin中,我们需要对起始触摸进行快照,然后在touchesMoved中连续检查并返回void,如果当前触摸的x/y与起始触摸相同。 - Matt Fiocca

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接