0 Favourites

How do I Swipe

  • Hi,

    I'm searching for a lot of time how to control a character with a swipe touch.

    Not only in 8 direction, but exactly as I swipe, or split the screen into two sides, horizontal and vertical.

    Is there a tutorial for this, I prefer video.

    Thanks,

    Idan

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • If it's sufficient for you to move your character as soon as the swipe ends (the user lifts his finger), you use this solution:

    • add the "Touch" object (obviously)
    • add two global variables "InitialX", "InitialY","CurrentX", "CurrentY" and "TouchAngle", all numbers
    • add an event "On touch start" with the following actions in it:

    --> Set InitialX to Touch.AbsoluteX (or .X, if that suits your project better)

    --> Set InitialY to Touch.AbsoluteY (or .Y)

    • add a condition "Is touching" with the following actions in it:

    --> Set CurrentX to Touch.AbsoluteX (or .X)

    --> Set CurrentY to Touch.AbsoluteY (or .Y)

    • add an event "On touch end" with the following actions in it:

    --> Set TouchAngle to "angle(InitialX,InitialY,CurrentX,CurrentY)"

    Now the swipe direction is stored in the TouchAngle variable.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
99 10,159
karshinkoff's avatar
karshinkoff
Unread hot topic
56 4,736
MPPlantOfficial's avatar
MPPlantOfficial
Unread hot topic
0 Favourites
Why is Stencyl doing better?
44 16,859
Potato's avatar
Potato