Search the Community
Showing results for tags 'Phaser keyboard movement'.
-
Hello! I want to create full keyboard movement in my game but i have a problem. I am trying and trying a lot of way and nothing. Now i ended on this: if(this.cursors.left.isDown) { this.player.animations.play('left'); this.lastanimation = 'left'; this.player.body.velocity.x -= 70; } else if(this.cursors.right.isDown) { this.player.animations.play('right'); this.lastanimation = 'right'; this.player.body.velocity.x += 70; } else if(this.cursors.up.isDown) { this.player.animations.play('up'); this.lastanimation = 'up'; this.player.body.velocity.y -= 70; } else if(this.cursors.down.isDown) { this.player.animations.play('down'); this.lastanimation = 'down'; this.player.body.velocity.y += 70; } else { this.player.animations.stop(); this.player.frame = 0; } },Want to move my sprite in 4 directions , and when holding the one arrow , I would like to push the second and chenge sprite direction . Now that I have, but not quite. Holding the left arrow and press the down sprite still goes to the left , but holding down and pressing the left nice change direction. I know that is because IF and else is conditional, but maybe anyone have way to do good keyboard movement with animations? How it work you can look on my page : http://lifetime.cba.pl LOGIN : test PASSWORD : test. Then click "GRAJ" to load the game. I will be grateful for help.