Skip to content

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

Description

@markckim

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)
    }

    ...

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions