Jump to content

Problem: can't create smooth jump behaviour (for player)


kidos
 Share

Recommended Posts

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

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

 Share

  • Recently Browsing   0 members

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