Jump to content

Tap to move


brianwik
 Share

Recommended Posts

Hi all, so I'm still very new to Phaser but I really want to learn this!

 

So my first question is ... instead of holding down the left or right key to move I want to set it so that you have to repeatedly tap the right button to move right instead of holding it down.

So every time the right key is tapped a small like 1 frame animation will happen and the character will move say 3 pixels forward. so this will continue every time you tap.

 

hope I made this clear enough and thanks in advance! :)

Link to comment
Share on other sites

Instead of polling the cursors for isDown in the update like most examples, you'd use the provided Signals (events) on the Key objects, something like this: http://jsfiddle.net/lewster32/mStRx/

 

This solution isn't totally ideal - it loses the ability to move diagonally for instance, but it should be fine for most applications. If you need diagonals as well, you'd have to add a bit more complexity to the code.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...