Jump to content

addPolygon change position image


olegawrt
 Share

Recommended Posts

Hello,

 

I have a problem when I use addPolygon. Polygon change position image. When I turn on debug I see images, and new shape draw in center. Second problem I don't now why image and shape Polygon is different. How fix this problem ? I not seen problem when I use addRectangle. Image and new shape is corect in tile 70px x 70px.

 

Code:



function create() {
...
groups.tile = game.add.group();
groups.tile.enableBody = true;
groups.tile.enableBodyDebug = true;
groups.tile.physicsBodyType = Phaser.Physics.P2JS;
groups.tile.collideWorldBounds = false;
...


var obj = groups.tile.create((x * map.width) - (map.width / 2), (y * map.height) - (map.height / 2), spriteName, numberTile);
obj.body.static = true;
obj.body.fixedRotation = true;
obj.body.collideWorldBounds = true;
obj.body.clearShapes();
var myPolygonArray= [ [0,0], [0,70], [70,70], [70,46], [25,46], [25,0]];
obj.body.addPolygon({}, myPolygonArray);

}


 

Example: 

 img_line.png

 

img_line1.png

 

img_line_debug.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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