Jump to content

Player movement control on touch devices


JohnD
 Share

Recommended Posts

I am trying to create movement controls for my game. I created an Up button, which, when held down, should make the player go upwards. The problem is that it only goes up once by 5 pixels when clicked. I tried to use isDown, but I don't know how to use it with buttons, only with keyboard controls. What is the correct way to do it?
 
In Create
buttonUp = game.add.button(16, game.world.centerY, 'button_up', goUp, this, 0, 1);buttonUp.anchor.setTo(0, 1);buttonUp.fixedToCamera = true;

In Update

function goUp() {    player.position.y -= 5;}
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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