khleug35 Posted January 18, 2018 Share Posted January 18, 2018 I use the following example to get start. https://phaser.io/examples/v2/arcade-physics/shoot-the-pointer When the arrow's angle <= 90 and >= 90, the arrow will stop move and can not shoot to the left!!!! I use the follow code function update() { //right if(sprite.angle <= -90 && sprite.angle >= -180){ sprite.angle=-90; } else if(sprite.angle >= 90 && sprite.angle <= 180){ sprite.angle=90; } //left /* if(sprite.angle >= -90 && sprite.angle <= 0){ sprite.angle = -90; } else if(sprite.angle <= 90 && sprite.angle >= 0){ sprite.angle = 90; } */ } But I hope the bullet not shoot to the left, any idea??? Thanks you so much Here is the jsfiddle link, Thanks https://jsfiddle.net/sjrup0h2/ Link to comment Share on other sites More sharing options...
gauravD Posted January 18, 2018 Share Posted January 18, 2018 You need to add the same angle constraints to bullet firing too. So instead of firing when the pointer is down, if (game.input.activePointer.isDown){ fire(); } you fire when the pointer is down and your sprite follows your angle constraints. if (game.input.activePointer.isDown && sprite.angle >= -90 && sprite.angle <=90){ fire(); } khleug35 1 Link to comment Share on other sites More sharing options...
khleug35 Posted January 18, 2018 Author Share Posted January 18, 2018 1 hour ago, gauravD said: You need to add the same angle constraints to bullet firing too. So instead of firing when the pointer is down, if (game.input.activePointer.isDown){ fire(); } you fire when the pointer is down and your sprite follows your angle constraints. if (game.input.activePointer.isDown && sprite.angle >= -90 && sprite.angle <=90){ fire(); } Works perfectly!!! You are so awesome!!!Thank you very much and have a nice day!! gauravD 1 Link to comment Share on other sites More sharing options...
Recommended Posts