Jump to content

Mobile screen touch controls


JamesAnd
 Share

Recommended Posts

Hello,

I would like to know if it is possible to have screen touch controls on mobile instead of the buttons?

In my game i tried having buttons to jump and it functioned correctly... however I am looking for a way to make my character jump wherever we actually touch  the screen and not just one specific button.

is that possible?

 

Also is it possible to have movement controls such as the attached in Phaser? is this a good example: https://phaser.io/examples/v2/input/virtual-gamecontroller

 

Thank you!

Screenshot_20171211-193049.png

Link to comment
Share on other sites

Hi

you can use the

this.game.input.activePointer.isDown

to use the screen as a button - I used it in one of my original games 

http://html5gamer.mobi/phaser2/oscar/

I made so you can press a mouse button on the screen (mobile use) or you can press the up cursor on a computer to jump

sample code

if (this.cursors.up.isDown || this.game.input.activePointer.isDown){
		this.playerJump();
	} else if (this.cursors.up.isUp || this.game.input.activePointer.isUp){
		this.isJumping = false;
	}

Hope that helps

Eric

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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