Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Issues with setPolygon()


jancarlo
 Share

Recommended Posts

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


 

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...