Swipe Up/Down/Left/Right

0 favourites
  • 10 posts
From the Asset Store
A complete set of graphical user interface (GUI) to build 2D video games. With wood, nature, & jungle theme
  • I'd like to be able to swipe in either directions - up/down/left/right - and have a projectile launch from a character in that direction. How would this be done?

  • Make variables for touchstartx and touchstarty and check them against touch.x an touch.y to see the general direction of the movement is.

  • Make variables for touchstartx and touchstarty and check them against touch.x an touch.y to see the general direction of the movement is.Ok, there's a start. Many projectiles were created this way. so I did this:

    "trigger once"                          create projectile

    "touch 0 speed >5000"

         "touchstartx+300<touch.x"          set bullet speed...

                                            set bullet angle...

    Sometimes this works, but mostly projectiles will only go the right. I have no idea why.

  • You'd probably need two comparisons per direction:

    system compare two values: touch.x < touchstartx

    system compare two values: abs(touchstartx-touch.x)<abs(touchstarty-touch.y)

    would mean swipe left.

  • Manual entry

    AngleAt(index)

    AngleForID(id)

    Get the angle of motion of a specific touch in degrees by its zero-based index or unique ID. A touch must be moving across the device screen for this expression to contain a useful value.

    You can also get the angle of your swipe with Touch.AngleAt()

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Manual entry

    AngleAt(index)

    AngleForID(id)

    Get the angle of motion of a specific touch in degrees by its zero-based index or unique ID. A touch must be moving across the device screen for this expression to contain a useful value.

    You can also get the angle of your swipe with Touch.AngleAt()I've read the entry and don't quite get the terminology. Do I just put a zero in the parenthesis?

  • the index nmbr is the nth touch

    like

    0 = first touch

    1 = second

    etc

  • the index nmbr is the nth touch

    like

    0 = first touch

    1 = second

    etcOk. I want this to work on every touch so I don't see this working. Unless it resets every time and the purpose is to keep track of fingers on the screen at the same time.

  • No it doesnt keep counting them hahah.

    Its a method to generally detect the second or third touch, like the double tap.

    Generally youd be aiming for 0.

    Just imagine if you use two fingers to swipe two different slab,one of the swipes would have 1 :)

  • No it doesnt keep counting them hahah.

    Its a method to generally detect the second or third touch, like the double tap.

    Generally youd be aiming for 0.

    Just imagine if you use two fingers to swipe two different slab,one of the swipes would have 1 :)That would make a lot more sense.

    Anyway, I get all these concepts, but am still not sure exactly how to go about this. How do I create just one projectile per swipe?

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