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:
and game:
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
Post a Comment