java - Box2D wrong body rotation -


i making map tiled , load box2d bodies box2dmapobjectparser world , work fine except 1 thing. i'm using newer version of tiled implemented body rotation. i'm trying implement in box2dmapobjectparser myself , it:

editor: enter image description here

and game: enter image description here

as can see right rectangle has property named rotation can properties, don't know wrong it.

i set rotation this

fixture.getbody().settransform(fixture.getbody().getposition(), degree); 

where degree value editor. have clues doing wrong? tried doing

fixture.getbody().settransform(fixture.getbody().getposition(), degree*mathutils.degreestoradians); 

but itsalso sets wrong rotation.

tiled rotates rectangle objects top-left corner. box2d rotates around position of body, easiest solution create box fixture such position of body in top-left (if you're using b2polygonshape::setasbox means passing center @ half width , half negative height (since y axis inverted)).


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -