Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Weird behaviour of CurrentTouch.BEGAN

in Bugs Posts: 142

I've noticed that when writing e.g. if CurrentTouch.state == BEGAN then ... end it registers inputs while the screen is being touched and not just when the state is BEGAN. So when typing something like:

if CurrentTouch.state == BEGAN then
     print("State is BEGAN")

The print statement will be called for the entire time the screen is being touched. Maybe I'm getting something mixed up, but as far as I remember, this behavior is new and previously it would only call the print statement once. I could be wrong, however. Maybe I'm just using it in a wrong way. (I'm on the latest version released on the AppStore, in case it is indeed a bug).


  • Posts: 791

    I don't think its a bug, but rather the imperfections of CurrentTouch to manage touch functions.

    I believe BEGAN is the state of a touch event from the moment it starts until it detects movement then the state becomes MOVING.

    If you use the function touched(touch) to deal with touches then it produces the effect you describe as function touched(touch) is only called when the touch changes, and therefore will always be MOVING (or ENDED or CANCELLED) after the first call (which is why you can utilise it as a one off BEGAN trigger).

    Calling CurrentTouch.state in the draw cycle will hold the BEGAN state if you don't move as the function to update the touch won't trigger.

    I try to avoid use of currentTouch if at all possible - I see it as a bit of a rough and ready hack to quickly test stuff if needed, but don't rely on it - what is the concept of a current touch when you have multiple fingers on the screen?

Sign In or Register to comment.