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

Box2d & Object layer


Jazz
 Share

Recommended Posts

Hey all,

 

Iam using the Box2d plugin in combination with tiled.

 

I have a seperate object layer that i want to use to create body/collisions, i noticed that box2d plugin does not have the convertCollisionObjects function so i tried to put it in myself:

convertCollisionObjects: function (map, layer, addToWorld) {        if (addToWorld === undefined) { addToWorld = true; }        var output = [];		        for (var i = 0, len = map.collision[layer].length; i < len; i++)        {            var object = map.collision[layer][i];	    var vertices = [];	    for (var i = 0, len = object.polyline.length; i < len; i++)            {	       vertices.push(object.polyline[i][0])	       vertices.push(object.polyline[i][1])	    }	    console.log(vertices);	    var body = this.createPolygon(object.x, object.y, vertices);            body.setPolygon(object.polyline)	    body.setPolygon(object.polyline)            if (body)            {                output.push(body);            }        }        return output;    },

vertices that is given as input: ([0, 0, 0, -32, 32, -32, 32, -64, 128, -64, 128, -32, 160, -32, 160, 0, 0, 0])

 

gives me the following error:

Untitled.png

 

does anyone know what im doing wrong? or are there any other ways to get tiled objects from tiled?

 

cheers!

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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