valueerror Posted November 5, 2014 Report Share Posted November 5, 2014 http://www.aurelienribon.com/blog/projects/physics-body-editor/ this nice tool does everything i need so there would be no need for physicsEditor - unfortunately the resulting project file seems to be useless with phaser.. but the data is there.. it's just structured in a different way.. look at the examples (those are two different shapes ) this is physics body editor{"rigidBodies":[{"name":"xx","imagePath":null,"origin":{"x":0,"y":0},"polygons":[[{"x":0.30000001192092896,"y":0},{"x":0,"y":0.30000001192092896},{"x":0,"y":0}]] ... ... ... ...and this is physicsEditor{ "bullet": [{"density": 2, "friction": 0, "bounce": 0, "filter": { "categoryBits": 1, "maskBits": 65535 },"shape": [ 66, 46 , 23, 46 , 10, 39 , 0, 25 , 11, 11 , 24, 5 , 66, 5 ]} ] ................ Quote Link to comment Share on other sites More sharing options...
wayfinder Posted November 5, 2014 Report Share Posted November 5, 2014 You can load the JSON and pass the shape array to p2body.addPolygon, it takes a flat list. Quote Link to comment Share on other sites More sharing options...
valueerror Posted November 11, 2014 Author Report Share Posted November 11, 2014 is it possible that you mixed up those two? the "flat" shape array is form physics editor.. the array from the free physics body editor is this one"polygons":[[{"x":0.30000001192092896,"y":0},{"x":0,"y":0.30000001192092896},{"x":0,"y":0}]] Quote Link to comment Share on other sites More sharing options...
wayfinder Posted November 11, 2014 Report Share Posted November 11, 2014 ah okay.. well in that case, you can parse it - shouldn't be too hard!var poly = new Array();for (i=0; i<polygons[0].length;i++) { poly.push(polygons[0][i].x, polygons[0][i].y);}p2body.addPolygon({}, poly); Quote Link to comment Share on other sites More sharing options...
valueerror Posted November 11, 2014 Author Report Share Posted November 11, 2014 hey thank you very much.. i didn't think of that the only thing thats a little bit unclear to me right now is how i access the polygons array out of my "polygon.json" file. Quote Link to comment Share on other sites More sharing options...
shohan4556 Posted September 11, 2015 Report Share Posted September 11, 2015 I have the same problem can you pleas clear this how can I access the polygon.json file ? Quote Link to comment Share on other sites More sharing options...
shohan4556 Posted September 11, 2015 Report Share Posted September 11, 2015 hey thank you very much.. i didn't think of that the only thing thats a little bit unclear to me right now is how i access the polygons array out of my "polygon.json" file. I have the same problem can you pleas clear this how can I access the polygon.json file ? should I link the .json file to main index.html file then access it ? Quote Link to comment Share on other sites More sharing options...
shohan4556 Posted September 11, 2015 Report Share Posted September 11, 2015 var poly = [];// note : parsing json$.getJSON('my_assets/addPhysics/testPhysics.json', function(data) {$.each(data.rigidBodies, function(i, body) {$.each(body.polygons, function(j, polygon) {$.each(polygon, function(k, coords) {poly.push([coords.x, coords.y]);});});});});ball1.body.clearShapes(); ball1.body.addPolygon({},poly);I have tried this but its not working. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.