CodeAndWeb / PhysicsEditor-Loaders

Use these classes to load the plist/xml file written by PhysicsEditor
39 stars 21 forks source link

Fixtures export with a top-right translation #18

Open katccat opened 4 weeks ago

katccat commented 4 weeks ago

When I chose the LibGDX exporter I kept noticing that bodies created using data from the PhysicsEditor would end up nowhere near the location of the Box2d BodyDef passed to the createBody method of the PhysicsShapeCache object. That is because as long as you draw fixtures within the canvas borders, every coordinate will be positive and that is either an oversight or it is just handled incorrectly by the loader. For example, in order for this fixture to be centered horizontally in game, it has to be clipping in the middle of the editor's left wall.

Screenshot 2024-08-24 at 22 13 24
CodeAndWeb commented 2 weeks ago

It might also depend on how you use your sprites. If this is the correct offset, it looks to me like you are using a trimmed sprite and draw it around its center - but it's hard to know from the details you are providing here.

Can you check out this tutorial: https://www.codeandweb.com/physicseditor/tutorials/libgdx-physics

It might help you getting it fixed.