Jump to content

Best way to add a pixel perfect static triangle?


maximinus
 Share

Recommended Posts

I have the co-ordinates of a triangle that I want to be a static phsyics object in matter.js. My code is:

var triangle_points = this.matter.world.fromPath('0 0 100 0 0 100');
var triangle = this.matter.add.image(x, y, 'image', null,
                                     {shape: {type: 'fromVerts', verts: triangle_points}});
triangle.setStatic(true);

 

However, when this object is added, the triangle is offset by the center of mass of the triangle.

How do I either prevent this, or work out the co-ord offsets so I can move the triangle back to the exact pixel position I need?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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