di-de Posted December 1, 2020 Share Posted December 1, 2020 I want to deploy my game to Android through Apache Cordova, so I need buttons on screen for movement. I have tried it doing and almost succeeded. I am using Phaser 3.24.0 and Arcade Physics. My independent move function: function move(dir) { if (dir == "left") { this.player.setVelocityX(-100); this.player.anims.play('move', true); this.player.flipX = true; } else if (dir == "right") { this.player.setVelocityX(100); this.player.anims.play('move', true); } else { this.player.setVelocityX(0); this.player.anims.play('idle', true); } } And the update function : function update() { if (cursors.left.isDown) { move("left"); } else if (cursors.right.isDown) { move("right"); } else { move(); } this.leftArrow.on("pointerdown", function() { move("left"); }); this.rightArrow.on("pointerdown", function() { move("right"); }); } The keyboard function works very well, and when I press the button (sprites) it moves for just a few pixels and stops. What can be done to achieve the desired effect? Link to comment Share on other sites More sharing options...
Recommended Posts