How do I check if the touch is moving ?

0 favourites
  • 4 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • I am working on game where you need to draw a line and there is a bar its width will decrease anytime you draw the line,

    I used (on create) event to this:

    on create line ----> subtract 1 from line_width

    (line_width) is the variable added to the bar width,

    the problem is the bar width will decrease if you just keep touching the screen without moving your finger and I want the bar with to decrease just if you touch the screen and moved your finger,

    and my question is can I check if I am touching the screen and moving my finger, not just touching?

  • Add two variables - previousX and previousY.

    On every tick check if Touch.X=previousX and Touch.Y=previousY. If not, this means that the finger has moved. After that save new touch position into these variables.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Add two variables - previousX and previousY.

    On every tick check if Touch.X=previousX and Touch.Y=previousY. If not, this means that the finger has moved. After that save new touch position into these variables.

    do you mean two global variables, and what their initial value should be ?

  • The variables could be global, or local static, or instance - doesn't really matter.

    Initial values could be 0. If you want to decrease the bar only when the finger is moving (not on initial touch), then you need to add another event "On touch start -> set previousX to Touch.X, set previousY to Touch.Y"

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)