Jump to content

is it possible to use the free physics body editor to create polygons for phaser?


valueerror
 Share

Recommended Posts

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  ]}  ]  ................
Link to comment
Share on other sites

  • 9 months later...

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 ? 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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