Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLAnalogJoystickHiddenArea capturing touches outside of its frame, misplacing the joystick outside of the hidden area. #11

Open
markckim opened this issue Jan 21, 2022 · 0 comments

Comments

@markckim
Copy link

markckim commented Jan 21, 2022

When tapping quickly many times on the TLAnalogJoystickHiddenArea node and progressively moving your touches outside of its frame, I noticed that it can capture touches outside of its frame which can place the TLAnalogJoystick outside of the hidden area.

I wasn't able to isolate the root cause of this, but here's a suggested solution, modifying TLAnalogJoystickHiddenArea's touchesBegan method to sanity check touchLocation before proceeding further. This fixed the issue on my end.

class TLAnalogJoystickHiddenArea: SKShapeNode {

    ...

    open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        guard let currJoystick = self.currJoystick else {
            return
        }

        let firstTouch = touches.first!
        let touchLocation = firstTouch.location(in: self.scene!)
        guard let path = self.path, path.contains(touchLocation) else {
            return
        }

        currJoystick.position = touchLocation
        currJoystick.isHidden = false
        currJoystick.touchesBegan(touches, with: event)
    }

    ...

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant