Jump to content

Phaser Virtual Joystick show on touch on one side of screen only?


dancramp
 Share

Recommended Posts

Hi,

 

I'm trying to implement the new virtual joystick and want to use the show on touch version so that the stick only appears/is activated on the left side of the screen leaving the right side for a fire/jump button or similar.

 

I may be being a bit dumb, but can't work out how to do this. When pressing a button it activates both the fire/jump and the directional (and show's the joystick underneath).

 

Any advice gratefully received!

 

Thanks.

Link to comment
Share on other sites

There's no "native" way to do this, but you could override the 'onDown' handler with something like this:

stick = pad.addStick(0, 0, 200, 'arcade');stick.showOnTouch = true;// remove default handlerstick.pad.game.input.onDown.remove(stick.checkDown, stick);// add in your owngame.input.onDown.add(checkDown, this);function checkDown(pointer) {  if (pointer.x < game.width / 2)  {    // right place? then call the Sticks checkDown method    stick.checkDown(pointer);  }}
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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