mobile/mouse "gestures"

0 favourites
  • 8 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Is there a way to get a sprite to follow a mouse or touch gesture?


    if I draw a "c" shape on screen with the mouse or mobile touch, then the spirite should follow the path of Thr shape created

    (this in theory I assume should move a sprite at an angle in a straight line)

    Touch -> on touch --> set spriteStart.X to Touch.X

                                        set spriteStart.Y to Touch.Y

    Touch -> on release --> set spriteEnd.X to Touch.X

                                             set spriteEnd.Y to Touch.Y

    Sprite -> move --> sprite.X = spriteEnd.X-spriteStart.X

                                   sprite.Y = spriteEnd.Y-spriteStart.Y

                                   Move at angle (sprite.X, sprite.Y)


  • There's a flow in your logic there.

    Since you are drawing a "C", the "path" should be an array containing the x,y positionf of the mouse during the path was drawn, not just the starting point and the ending point.

    So it seems to me you should put up some "record" system, that will keep in memory the points where the mouse went by and THEN move the sprite from positions to positions until it reaches the end point.

    That would be for a case where you first draw your path and then move the sprite.

    If the sprite is to follow the path as it is drawn, then every X sec, set the sprite position to the current mouse/touch position.

    Depending on the interval X, the movement can be more or less precise.

    To know about sprite movements, check this topic out.

  • Kyatric

    With that being said, is there a way to create a "dynamic" array?


    Create a static array

    Move the mouse-> populate the array & count each set of coordinates

    For loop to cycle thru the array to move the sprite

    ??? (seems like a lot of unnecessary coding...not sure)

  • This plug: Data Structures

    Would be ideal using 2 timers and a lerp, plus another copy of the plug for the y, unless C2 gets variable vectors at some point.

    You could use the array object as well, but you would be limited in how many nodes you could add.

    Then again, it might be possible to create local variables here as well.

    Dunno for sure have delved into them much yet.

  • I've ported this from construct classic, original was made by R0j0hound i think :)

    <img src="" border="0" />

    and the .capx:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Kewlbeanz thanx Ize

  • well its not really what you wanted originally but maybe you can do something with it :D

  • Sorry to reanimate this old thread, but the link from Ize does not work ...

    Can anyone post an actual link/file/example?

    Thanks alot and Happy Halloween

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