Bubbles Posted September 20, 2016 Share Posted September 20, 2016 (edited) Hey everyone! So I'm pretty new to Phaser and I'm having a hard time making the player's bullets stop at a certain point (e.g killing the projectile at around 30px after its original position, etc). I want the player to have a limited projectile range and I'm just wondering how you can implement that because all my attempts of trying to figure it out have failed so far, so I'm seeking help from you guys... Thanks for any advise! Edited September 20, 2016 by Bubbles accidentally submitted an incomplete message Link to comment Share on other sites More sharing options...
squilibob Posted September 24, 2016 Share Posted September 24, 2016 If you want to calculate how far something is away from your player you can use game.math.distance(x1, y1, x2, y2) so you would use something like if (game.math.distance(x1, y1, x2, y2) > 30) ){ // destroy the object } x1 and y1 are the coords of your player x2 and y2 the coords of the object you are comparing Link to comment Share on other sites More sharing options...
samme Posted September 24, 2016 Share Posted September 24, 2016 Are you using Phaser.Weapon? Link to comment Share on other sites More sharing options...
Recommended Posts