Move a sprite with a touch gesture on one axis only?

0 favourites
  • 4 posts
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
  • Here's what I need to accomplish:

    I need to drag a sprite along the x or y axis according to the direction the user swipes, but once the sprite starts to move, it can only move on a single axis until the next touch. So no matter the direction of the swipe, whether it's diagonally or on the other axis, only the original axis registers until the user ends the touch and touches again.

    I can get the sprite to follow the touch, but I need them to move either horizontally or vertically. I'm pretty sure I need to acquire the direction of the swipe before anything else, but I'm completely stumped on how to do that.

  • I haven't fooled with touch much but I would start with looking at the fruit slicer tutorial, seems its slice might be useful.

    it uses the Touch on-any-touch-start set action1: variableX Touch.X action2: variableY Touch.Y

    then uses those to

    Set angle to angle (variableX, variableY, Touch.X, Touch.Y) degrees

    this would give you your angle swiped at least.

  • touch.AngleAt would give you the angle of your touch movement..

    round this to 0,90,180,270 and you only have the straight horizontal and vertical movement..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you so much you guys!!! I was able to setup a visual debugging system with that tutorial, which is super helpful. LittleStain I ended up using Touch.AngleAt(Touch.TouchIndex) to get the angle and it works perfectly!

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