iosdelaysprite-kitlagtouchesbegan

Tapping the very bottom of the screen causes lag/delay in touchesBegan


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


Solution

  • 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.