Jump to content

Best way to add a pixel perfect static triangle?


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}});


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


  • Recently Browsing   0 members

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