Pro Swipe Formula for Mobiles

0 favourites
  • 14 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Hey everyone, do you know about pro swipe? it's more than d-pad and analog stick, it's designed for mobiles with touch support.

    We create an invisible sprite for the whole screen it should to detect our fingers according the directions, if you swipe up, the character moves up, then you swipe down, the character moves down, swipe right, the caracter moves right. It shouldn't stop moving while touching is busy, when the touch ends, the character stops.

    Do you have an idea?

  • Joannesalfa : I didn't played Mage Gauntlet on iOS, but it's known for that kind of mechanism (perhaps you played it yourself, and it's given you the idea ? <img src="smileys/smiley2.gif" border="0" align="middle" />).

    I would do it like that :

    • every X milliseconds, set a "Starting Point" var as the current (Touch.X, Touch.Y)
    • X milliseconds, check the new (Touch.X1, Touch.Y1)
    • do a check :

    IF ((X1-X) > threshold, (X1-X) > 0, AND (Y1-Y) < variationOnAxis),

    THEN Move 10 pixels to the right.

    IF ((X1-X) < threshold, (X1-X) < 0, AND (Y1-Y) < variationOnAxis),

    THEN Move 10 pixels to the left.

    IF ((X1-X) < variationOnAxis, AND (Y1-Y) > threshold, (Y1-X) > 0),

    THEN Move 10 pixels to the bottom.

    IF ((X1-X) < variationOnAxis, AND (Y1-Y) < threshold, (Y1-X) < 0),

    THEN Move 10 pixels to the top.

    The idea is to 1) set a variation on the vertical or horizontal axis that allows the player to draw lines that aren't "exactly" vertical or horizontal, and 2) check if his finger has moved farther than a pre-determined threshold in one of those direction.

  • Joannesalfa : I didn't played Mage Gauntlet on iOS, but it's known for that kind of mechanism (perhaps you played it yourself, and it's given you the idea ? <img src="smileys/smiley2.gif" border="0" align="middle" />).

    I would do it like that :

    - every X milliseconds, set a "Starting Point" var as the current (Touch.X, Touch.Y)

    - X milliseconds, check the new (Touch.X1, Touch.Y1)

    - do a check :

    IF ((X1-X) > threshold, (X1-X) > 0, AND (Y1-Y) < variationOnAxis),

    THEN Move 10 pixels to the right.

    IF ((X1-X) < threshold, (X1-X) < 0, AND (Y1-Y) < variationOnAxis),

    THEN Move 10 pixels to the left.

    IF ((X1-X) < variationOnAxis, AND (Y1-Y) > threshold, (Y1-X) > 0),

    THEN Move 10 pixels to the bottom.

    IF ((X1-X) < variationOnAxis, AND (Y1-Y) < threshold, (Y1-X) < 0),

    THEN Move 10 pixels to the top.

    The idea is to 1) set a variation on the vertical or horizontal axis that allows the player to draw lines that aren't "exactly" vertical or horizontal, and 2) check if his finger has moved farther than a pre-determined threshold in one of those direction.

    Yes, it's inspired by Mage Gauntlet on iOS.

    I'm going to try out your idea, so i hope it will be worked.

  • Actually, i failed to attempt your formula...

    Do we will use 8 dir movement behavior that simulates movement according to TouchY and TouchX?

  • Would you make a .capx example? it would be awesome!

  • Heres an example I made showing player movement with swipe motions. Swipe anywhere on the game window to move the player. The longer the swipe the longer the player moves

    Live Demo

    capx here

    it includes pretty much everything already set up to use the swipe data for whatever

  • Heres an example I made showing player movement with swipe motions. Swipe anywhere on the game window to move the player. The longer the swipe the longer the player moves

    Live Demo

    capx here

    it includes pretty much everything already set up to use the swipe data for whatever

    I was hoping for your awesome example, actually it's not exactly "Pro Swipe" because when you do "Touching" then swipe, it does nothing until touch ends it moves.

    In event number 2, i changed "On Touched End" to "Is in Touch" it works as pro swipe but not precisely, you can simulate touch using Chrome.

    Do your mouse makes a circle movement while click is holding it may act as touching.

    Do you have an idea how to stop moving character when touching is end?

  • bMove is the instance var on the player that controls it movin. That gets set to false when movetime is >= the time based on the touch distance

    And yeah it doesnt move if you just touch and not swipe because theres a global controlling it. If the distance between touch start and touch end isnt greater than that threshold it doesnt trigger movement

  • bMove is the instance var on the player that controls it movin. That gets set to false when movetime is >= the time based on the touch distance

    And yeah it doesnt move if you just touch and not swipe because theres a global controlling it. If the distance between touch start and touch end isnt greater than that threshold it doesnt trigger movement

    Thanks a lot for clearing that! :)

  • I am also looking for similar solution.

    Example: swipe from left to right or right to left would bring up some sprite. And swipe from top to bottom or bottom to top would bring up some sprite.

    Can anyone submit a capx?

  • rohit555,

    aridale's capx kinda works.. check.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I am also looking for similar solution.

    Example: swipe from left to right or right to left would bring up some sprite. And swipe from top to bottom or bottom to top would bring up some sprite.

    Can anyone submit a capx?

    Do you need this to happen whilst swiping, or is activating a new sprite after swiping okay? Because if you compare touch.X at the start of a swipe to the touch.X at the end of a swipe, you can work out whether a swipe is going left or right, and checking the Y variable will tell you if it's going up or down.

  • Yeah, capx is super!

    But it would be much cooler if character will repeat circle path, to example.

  • Here:Link is a capx with my version of a scroll swipe based on touch's angle, and speed.

    Its clamped, and angled to my personal preferences, but there's plenty of ways to tweek it.

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