Using non-convex polygons sprites (P2 physics)

Recommended Posts

I started using Phaser recently, and I came across a problem that kind of annoyed me since I didn't find any really satisfying answers yet (on this forum or anywhere on the internet)

I'm trying to create non-convex polygon-shaped sprites, I know I have to use P2 physics to accomplish that, and precisely the loadPolygon function. The thing is, everyone seems to be working with PhysicsEditor to generate JSON files to feed this function, and I'm looking for a free alternative.

I eventually found 2 alternatives, but :

- : doesn't seems to work (clicking on "downloads" or "URLs & code" does absolutely nothing)

- : for some reason, everytime I click "New image", my PC freezes to death... (I tried on a different PC and it works, but even then you have to create manually all the "polygon groups", and I'm looking for something that would generate these for me)

I put together a little editor that lets you define points on a sprite and triangulate the polygon to create the desired JSON file (that contains the list of these triangles), but I'm wondering if there is a simpler way to answer this problematic ? I also tried to use addPolygon, but there was this weird offset because Phaser wants to adjust the center of mass, I didn't find how to avoid that (just commenting the call to the function which adjust the center of mass, as I've read on this forum, didn't do the trick, the offset was different but still there)


Thanks !

Share this post

Link to post
Share on other sites

Thank you!

I had already tested this one, but not successfully, and the fact that its last update is from 2012 had me thinking it wasn't the response to my problem...

Well, I insisted and this actually seems to be perfect! I just have to write something to converts the output to the phaser format, but it seems easy enough


I guess I can stop working on my editor, even though it was fun to learn a few things about polygon triangulation/decomposition ^_^

Share this post

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.