SpriteKit SKScene缺少touchesEnded [英] SpriteKit SKScene missing touchesEnded

查看:136
本文介绍了SpriteKit SKScene缺少touchesEnded的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到touchesEnded并不总是通过多点触控传递给SKScene。根据移除手指等的速度,我会永远错过一些touchesEnded。 touchesCancelled已实现,我添加了一个自定义UIView并放在屏幕的左侧 - 没有问题。我做了一个自定义的SKView并捕获了事件 - 再次没有问题。

I've noticed that touchesEnded don't always get delivered to an SKScene on multi touch. Depending on speed of removing fingers etc, I would permanently miss some of the touchesEnded. touchesCancelled is implemented and I added a custom UIView and put over the left side of the screen - no problems. I made a custom SKView and captured events - again no problem.

很明显,SKScene没有得到所有的触摸它嵌入的SKView,但为什么?

It's obvious that SKScene doesn't get all the touchesEnded the SKView it's embedded in, but why?

(顺便说一句,我完全没有任何节点地运行SKScene)

(BTW, I'm running the SKScene completely without any nodes)

编辑:

一些进一步的调查显示我可以让SKScene完全失去联系:

Some further investigation reveals I can get SKScene to lose a touch entirely:

我把3个手指放在显示器上然后将它们移除一个只有一根手指接触的时间。我移动手指 - >只有SKView收到移动事件,SKScene没有。它也没有收到touchesEnded。

I put 3 fingers on the display then remove them one at a time until only one finger touches. I move the finger -> only the SKView receives the move events, the SKScene doesn't. Nor does it receive the touchesEnded.

经过一些实验,我可以说当一个touchesBegan在一次通话中接到超过1次触摸时(例如你同时按下两根手指)就会发生这种情况)。这两个接触然后被纠缠,所以只有其中一个发送事件。

After some experimentation I can say that it happens when a touchesBegan receives more then 1 touch in a call (e.g. you press two fingers "simultaneously"). These two touches then get entangled so only one of them sends events.

这似乎是SKScene中的一个错误。我正在iPhone 5上测试。它会

This appears to be a bug in SKScene. I'm testing on an iPhone 5. It would

推荐答案

可能你正在使用一些gestureRecognisers?
他们拥有 cancelsTouchesInView 属性,其默认值为 YES
将其更改为解决了我的问题。

May be you are using some gestureRecognisers? They have property cancelsTouchesInView and it's default value is YES. Changing it to NO solved my problem.

这篇关于SpriteKit SKScene缺少touchesEnded的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆