kidos Posted July 4, 2014 Share Posted July 4, 2014 Hi All,I'm fairly new to Phaser, and I really like it, also it's great to see this community keeps growing...!I'm working with Phaser 2.0.5 and CocoonJS 2.0.1 for mobile compiling. While studying Phaser I followed "Making your first Phaser game" and wanted to port it to mobile and to add a jump option.So, I've added 2 buttons for going left and right instead of the keyboard and another button for jump: So, I added to the preload function:game.load.image('arrow_left', 'assets/arrow_left.png');game.load.image('arrow_right', 'assets/arrow_right.png');game.load.image('arrow_jump', 'assets/arrow_up.png');Added to the create function:goleft = game.add.button(10, game.world.height - 65,'arrow_left');goleft.inputEnabled = true;goright = game.add.button(80, game.world.height - 65,'arrow_right');goright.inputEnabled = true;jump = game.add.button(700, game.world.height - 65,'arrow_jump');jump.inputEnabled = true;And, changed the IF statements to work with touch for each move (left, right and jump)if (cursors.left.isDown || goleft.input.pointerDown(game.input.activePointer.id))else if (cursors.right.isDown || goright.input.pointerDown(game.input.activePointer.id))if ((cursors.up.isDown || jump.input.pointerDown(game.input.activePointer.id)) && player.body.touching.down)(here's the full code part9.html ) Everything works well with the touch but it doesn't feel smooth, the player can do only one action each time, for example: if the player wants to jump right he needs to release the "right" button, press "jump" and then press again on the "right".How can I make all of the player moves work together? btw, with the keyboard it's working perfect. Thanks..! Link to comment Share on other sites More sharing options...
valueerror Posted July 5, 2014 Share Posted July 5, 2014 http://www.html5gamedevs.com/topic/1813-the-monthly-phaser-examples-contest/?p=27173try this.. maybe it helps.. Link to comment Share on other sites More sharing options...
kidos Posted July 7, 2014 Author Share Posted July 7, 2014 http://www.html5gamedevs.com/topic/1813-the-monthly-phaser-examples-contest/?p=27173try this.. maybe it helps.. Thanks, it helped a bit.But since you're using onInputOver sometimes the button "get stuck" in pressed mode and the player is moving without touching the screen.Is there a way to fix that? Link to comment Share on other sites More sharing options...
valueerror Posted July 8, 2014 Share Posted July 8, 2014 in my game i fixed it with this line: if (game.input.currentPointers == 0 && !game.input.activePointer.isMouse){ fire=false; right=false; left=false; duck=false; jump=false;}rich tried to fix this in phaser once.. maybe we should open a github issue for this ? Link to comment Share on other sites More sharing options...
Recommended Posts