1

I have a scene with multiple layers (SKNodes) background, gamelayer, foreground and hud and each have multiple SKSpriteNodes in them for scrolling and objects you can collect and hit.

The hud layer just has an SKSpriteNode (alpha coloured) and a couple of SKLabelNodes on for score and level, tapping anywhere on the screen (except the small score area) results in an instant touchesBegan event firing (fab) BUT... tapping in the tiny hud score area at the bottom introduces a lag/delay before the touchesBegan fires.

Could an SKSpriteNode or the Labels be trapping the touchesBegan event or something and causing a delay?

I will be creating a simplified project to test this out and posting my findings but thought it might help someone else if this question/query gets answered. Thanks.

This is the closest post to my question but I don't have any gesture recognizers in my app delegate. Sprite Kit touchesbegan: delay/lag

2
  • 1
    You may be tapping on the Control Center area (the thing you can swipe up from the bottom where you can change wifi, brightness, and other settings). The Control Center uses a gesture recognizer internally. I believe there are ways to work around this, one workaround for yourself is to disable Control Center in apps via the Settings app.
    – CodeSmile
    Apr 23, 2014 at 11:14
  • Thanks for the response. I did consider that but thought nnaaarrr surely that won't affect my app, but if you can turn it off then that's one of the first things I will try. Tapping at the far bottom left or right still causes the lag though. Ultimately I will probably move the score area to the top but want to solve this issue first for other people getting the same behavior.
    – FoxTC
    Apr 23, 2014 at 14:28

2 Answers 2

1

I tried moving the score panel (SKSpriteNode and Labels) away from the bottom of the screen and touching them didn't produce the lag anymore. (So it's not them!)

Tapping the bottom of the screen still caused the lag.

I can confirm that LeanCocos2D's suggestion that Control Center is causing the delay is spot on. See excerpt from the official IOS7 UI Guide:

Expect users to swipe up from the bottom of the screen to reveal Control Center. If iOS determines that a touch that begins at the bottom of the screen should reveal Control Center, it doesn’t deliver the gesture to the currently running app. If iOS determines that the touch should not reveal Control Center, the touch may be slightly delayed before it reaches the app.

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/transitionguide/Scoping.html

In order to fix the issue as I really need people to be able to tap with a rapid response at the bottom of my screen was to include the following code in the ViewController:

- (BOOL) prefersStatusBarHidden
{
    return YES;
}

I really hope this helps.

1
  • Please could someone accept my answer as I'm trying to comment on other peoples questions and can't at the moment.
    – FoxTC
    Apr 29, 2014 at 7:01
1

Adding this in my AppDelegate's didFinishLaunchingWithOptions function:

for (UIGestureRecognizer* gesture in _window.gestureRecognizers)
{
    gesture.delaysTouchesBegan=NO;
}

cured the touch delay at the bottom of the screen for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.