Skeptron Posted March 7, 2016 Share Posted March 7, 2016 Hi guys, Does anyone know how one can make a sprite immovable ONLY ON THE X AXIS? Thanks! Link to comment Share on other sites More sharing options...
Skeptron Posted March 7, 2016 Author Share Posted March 7, 2016 I forgot to say, a sprite with a body! Link to comment Share on other sites More sharing options...
Skeptron Posted March 8, 2016 Author Share Posted March 8, 2016 Bump Link to comment Share on other sites More sharing options...
drhayes Posted March 8, 2016 Share Posted March 8, 2016 I would override the position setters to only accept changes according to a flag, or something. So you position it where you want it in the x, set the flag, now the thing can't be moved on the x-axis. It probably has weird effects on the physics. Link to comment Share on other sites More sharing options...
icp Posted March 8, 2016 Share Posted March 8, 2016 Add this.body.velocity.x = 0; right after you do the velocity and forces calculations, in your sprite's update method. Link to comment Share on other sites More sharing options...
Recommended Posts