Jump to content

Creating complex polygons from PNGs using PhysicsEditor

Recommended Posts



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 post
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 post
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.



Link to post
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...