Jump to content

Creating complex polygons from PNGs using PhysicsEditor


shaunumb
 Share

Recommended Posts

Hey 

 

I'm trying to find a tool that will let me export the correct style JSON to add to a sprite using the .setPolygon() method. 

 

I've tried all the export settings from PhysicsEditor and none seem to provide the correct JSON. Is this the best tool to be used to create points from a shape with a transparent background?

 

The polygon itself is quite complex, consisting of around 400 points. I wonder if it's even possible with this many points?

Link to comment
Share on other sites

Erm... actually it's a really long wiggly line so I guess it's both concave and convex. I can see it's plotted the points correctly in PhysicsEditor, but I don't really know what to do with the exported format. 

 

I need a simple 1D JSON array of x,y coords e.g. [0,50, 300,20... etc] , but what I get out of PhysicsEditor using the Lime + Corona setting (for example) is something like: 

 

{"density": 0, "friction": 0, "bounce": 0, "filter": { "categoryBits": 0, "maskBits": 0 },"shape": [   129, 5000  ,  129, 4980  ,  136, 4982  ,  134, 5000  ]}  ,{"density": 0, "friction": 0, "bounce": 0, "filter": { "categoryBits": 0, "maskBits": 0 },"shape": [   34, 3852  ,  31, 3874  ,  27, 3896  ,  25, 3870  ]}  ,{"density": 0, "friction": 0, "bounce": 0, "filter": { "categoryBits": 0, "maskBits": 0 },"shape": [   136, 4551  ,  147, 4566  ,  158, 4586  ,  143, 4571  ]}  ,
Link to comment
Share on other sites

Right, there is a way of getting the correct the coords from SpriteHelper App... however it seems that Phaser doesn't calculate the overlap correctly on concave polygons :(

 

I've attached a screenshot of the two elements not overlapping with debug on, but Phaser still sees it as an overlap.

 

phaser-overlap.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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