Jazz Posted November 7, 2015 Share Posted November 7, 2015 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: 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 More sharing options...
Jazz Posted November 8, 2015 Author Share Posted November 8, 2015 solved: had to filter out the last 2 zero's! Link to comment Share on other sites More sharing options...
Recommended Posts