SpriteKit SKScene missing touchesEnded
Asked Answered
J

1

9

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.

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

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

EDIT:

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

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.

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.

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

Jackknife answered 30/10, 2013 at 17:29 Comment(2)
any gesture recognizers running? multi touch enabled? received multiple touches ended in a single event?Gastongastralgia
@LearnCocos2D no gesture recognizers (just running a plain SKScene as test), multi touch enabled. I'm getting multiple touches in a single touchesBegan, and I'm also listing the other touches in the event. The lost touches simply disappears from allTouches when I detect a later touchesEnded.Jackknife
N
2

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.

Nita answered 19/3, 2014 at 13:22 Comment(1)
No, I made an entirely empty view to test.Jackknife

© 2022 - 2024 — McMap. All rights reserved.