Jump to content

Player movement control on touch devices


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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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