Jump to content

Joystick


enyce12
 Share

Recommended Posts

Hello everybody

 

I'm new to phaser and I've a question on how to realize a virtual joystick for mobile devices.

I get stuck with the following example: http://examples.phaser.io/_site/view_full.html?d=input&f=touch+joystick.js&t=touch%20joystick

 

That's where I'm so far: http://v-designs.ch/game/

 

I'm using the HTML5 Virutal Game Controller from the example above but I don't know on how to combine it ...

 

Any idea on how to make it work with my current code for desktop?

 

if (_this.game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {    _this.ship.body.angularVelocity = -_this.SHIP_ROTATION_SPEED;} else if (_this.game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {    _this.ship.body.angularVelocity = _this.SHIP_ROTATION_SPEED;} else {    _this.ship.body.angularVelocity = 0;}if (_this.game.input.keyboard.isDown(Phaser.Keyboard.UP)) {    _this.ship.body.acceleration.x = Math.cos(_this.ship.rotation) * _this.SHIP_ACCELERATION;    _this.ship.body.acceleration.y = Math.sin(_this.ship.rotation) * _this.SHIP_ACCELERATION;    _this.ship.frame = 1;} else {    _this.ship.body.acceleration.setTo(0, 0);    _this.ship.frame = 0;}if (_this.game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR)) {    module.shootBullet();}

 

Thank you for any advices!
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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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