Jump to content

Add Physics editor vertices to scene with no sprite


Recommended Posts


I am trying to add my vertices exported from Physics Editor but I just want the vertices added to my scene, there is no image or sprite. I have this working (albeit I think incorrectly) like this:

var paths =  this.cache.json.get('paths');
this.matter.add.sprite(255, 660, null, null, {shape: paths.pathBottom});

So I am putting null where there should be a reference to a spritesheet and sprite. This has the result of the little green rectangle appearing (because it can't find the image resource) (although I do get my custom shapes added)

I have been trying lots of things based on their examples but I can't figure out how to just add the vertices (maybe as a polygon?) but with no sprite or image. Can anyone help?


Many thanks




Link to comment
Share on other sites

Use this:

     * [description]
     * @method Phaser.Physics.Matter.Factory#fromVertices
     * @since 3.0.0
     * @param {number} x - [description]
     * @param {number} y - [description]
     * @param {array} vertexSets - [description]
     * @param {object} options - [description]
     * @param {boolean} flagInternal - [description]
     * @param {boolean} removeCollinear - [description]
     * @param {number} minimumArea - [description]
     * @return {MatterJS.Body} A Matter JS Body.
    fromVertices: function (x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea)
        var body = Bodies.fromVertices(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea);


        return body;

You can access it via `this.matter.add.fromVertices` in any Scene.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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