Search the Community
Showing results for tags 'multiple keys at once'.
-
I want multiple keys at once. If I use D + shift, the player will stop, how to fix it? SHIFT is to sprint the player and D is to walk the player on right side. This is my code: (game.input.keyboard.isDown(Phaser.Keyboard.A)) { if(carDriveV != 0) { car_1.body.velocity.x = -50; car_1.animations.play('c_drive'); } else if (boatDrive != 0) { boat.body.velocity.x = -50; facing = 'left'; boat.animations.play('boat_move_l'); } else { player.body.velocity.x = -50; if (facing != 'left') { player.animations.play('left'); facing = 'left'; } } } else if (game.input.keyboard.isDown(Phaser.Keyboard.D)) { if(carDriveV != 0) { car_1.body.velocity.x = 200; car_1.animations.play('c_drive'); } else if (boatDrive != 0) { boat.body.velocity.x = 50; facing = 'right'; boat.animations.play('boat_move_r'); } else { player.body.velocity.x = 50; if (facing != 'right') { player.animations.play('right'); facing = 'right'; } } } else if (game.input.keyboard.isDown(Phaser.Keyboard.SHIFT)) { if(carDriveV != 0) { carDriveV = 0; player.loadTexture('player'); game.camera.follow(player); player.body.x = car_1.body.x+130; } else if (boatDrive != 0) { } else { if (facing == 'left') { player.animations.play('sprint_left'); facing = 'left'; player.body.velocity.x = -150; } else { player.animations.play('sprint_right'); facing = 'right'; player.body.velocity.x = 150; } } }