Jump to content



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


  • Recently Browsing   0 members

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