jancarlo Posted February 19, 2014 Share Posted February 19, 2014 Hi guys, Hoping you can help me out. I'm currently using the setPolygon() method to modify the bounding box of one of my sprites. I'm setting the initial x and y coordinates to be somewhere in the middle of my canvas. Initially, I wasn't using the body.translate() method after calling setPolygon(), and my bounding box and sprite were spawning in the upper left corner of my canvas. After calling body.translate with my initial x/y coordinates, the bounding box now appears in the correct place, but the sprite image still spawns in the upper left corner. Any idea why this could be? Thanks,Jancarlo Link to comment Share on other sites More sharing options...
AlexArroyoDuque Posted February 19, 2014 Share Posted February 19, 2014 http://www.html5gamedevs.com/topic/3890-more-problems-113-to114-sprites-position/?hl=setrectangle My solution has been to define the position of the sprite after using setRectangle. this.game.add.sprite this.player = (200, 150, 'player'); this.player.body.setRectangle (75, 160, 0, 0); this.player.body.x = 200; this.player.body.y = 150; idem with setPolygon Link to comment Share on other sites More sharing options...
jancarlo Posted February 20, 2014 Author Share Posted February 20, 2014 Thanks Alejandro. Resetting the body position manually did the trick. Link to comment Share on other sites More sharing options...
Recommended Posts