przemoo83 Posted February 5, 2015 Share Posted February 5, 2015 HiI'm developing a simple game based on one of the tutorials. I came accross a problem. If the player is runnin (arrow pressed) and I press fire he always stops. I want him to keep running while shooting Is there any easy way to fix this? My code for controlling ther playerupdate: function() { this.game.physics.arcade.collide(ground, player); player.body.velocity.x = 0; if (grygiel.game.input.activePointer.isDown) { //fire fireBullet(); player.animations.play('throw'); } else if (cursors.left.isDown) { // Move to the left player.body.velocity.x = -450; player.animations.play('left'); } else if (cursors.right.isDown) { // Move to the right player.body.velocity.x = 450; player.animations.play('right'); } else { // Stand still player.animations.stop(); player.frame = 8; } // Allow the player to jump if they are touching the ground. if (cursors.up.isDown && player.body.touching.down) { player.body.velocity.y = -350; player.frame = 9; } //follow the player this.game.camera.follow(player); },}; Link to comment Share on other sites More sharing options...
charlie_says Posted February 6, 2015 Share Posted February 6, 2015 You're nearly there, you've got an extra elseupdate: function() { this.game.physics.arcade.collide(ground, player); player.body.velocity.x = 0; if (grygiel.game.input.activePointer.isDown) { //fire fireBullet(); player.animations.play('throw'); } // removed else here!! if (cursors.left.isDown) { // Move to the left player.body.velocity.x = -450; player.animations.play('left'); } else if (cursors.right.isDown) { // Move to the right player.body.velocity.x = 450; player.animations.play('right'); } else { // Stand still player.animations.stop(); player.frame = 8; } // Allow the player to jump if they are touching the ground. if (cursors.up.isDown && player.body.touching.down) { player.body.velocity.y = -350; player.frame = 9; } //follow the player this.game.camera.follow(player); },}; Link to comment Share on other sites More sharing options...
przemoo83 Posted February 12, 2015 Author Share Posted February 12, 2015 Thanks a lot:) Link to comment Share on other sites More sharing options...
Recommended Posts