Tuan Posted October 29, 2014 Share Posted October 29, 2014 Hi everyone, I'm following a Phaser tutorial by @bryanbibat , the Shoot'em up game. The function moveTopoiter is good when play the game by mouse cursor. However, it hides my view on mobile touch screen. So that I want to improve the controlling of player on mobile touch by swipe action. I tryng to replace these lines in the update function: if (this.input.activePointer.isDown && this.physics.arcade.distanceToPointer(this.player) > 15) { this.physics.arcade.moveToPointer(this.player, this.player.speed); }with these if (this.input.activePointer.isDown ){ this.player.body.velocity.x = (this.input.activePointer.position.x - this.input.activePointer.positionDown.x) * 2; this.player.body.velocity.y = (this.input.activePointer.position.y - this.input.activePointer.positionDown.y); } else { this.player.body.velocity.x = 0; this.player.body.velocity.y = 0; }It works but the control isn't good. It isn'e sensitivre and jitter. I've just read these post but it doesn't help. http://www.html5gamedevs.com/topic/3862-swipe-to-jump/http://www.html5gamedevs.com/topic/5449-directional-swipe/ Could anybody give me an advice? Link to comment Share on other sites More sharing options...
bryanbibat Posted October 30, 2014 Share Posted October 30, 2014 I'm not sure if swiping is a good control scheme for shmups since they require precision control. One way of preventing the player's finger from covering the player's sprite is to let the pointer be at the back of the sprite e.g. if (this.input.activePointer.isDown && this.physics.arcade.distanceToXY(this.player, this.input.activePointer.x, this.input.activePointer.y - 32) > 15) { this.physics.arcade.moveToXY(this.player, this.input.activePointer.x, this.input.activePointer.y - 32, this.player.speed); }Another way is to have an on-screen virtual d-pad. Link to comment Share on other sites More sharing options...
Tuan Posted October 31, 2014 Author Share Posted October 31, 2014 Thanks Bryan .I'll try yours and take a look at the virtual game d-pad. p/s: I'm trying to make the game similar to the Thunder Fighter 2048 https://play.google.com/store/apps/details?id=com.timelily.game.thunderfighter2048&hl=en Link to comment Share on other sites More sharing options...
Recommended Posts