java - LibGDX Angle/Rotation Issue -


i'm using tiled map editor create simple tiled map. within map have several rectangles, if create rectangle width of 50 , height of 10 , rotate 90°, save map , load in libgdx project, shape rendered correctly - if use random angle, let's 26° example , render map again, not desired result, in fact exact opposite desired angle.

i'm reading tiled map float directly map using:

 map map = new tmxmaploader().load(maplocation + mapname + mapextension);  (maplayer maplayer : map.getlayers()) {      (mapobject mapobject : maplayer.getobjects() {           mapproperties objectproperties = mapobject.getproperties();            float objectrotation = objectproperties.get("rotation") != null ? float.parsefloat(objectproperties.get("rotation").tostring)) : 0.0f;           objectrotation = mathutils.degrad * objectrotation;      }  } 

the mathutils.degrad converts degrees read directly map properties radians, somewhere along line there's misread happening or i've missed something.

later, create bodydef , set angle above mentioned objectrotation using bodydef.angle = objectrotation followed creating body default values.

you're missing bit of math.

mathutils.cosdeg( angleindegrees ) mathutils.sindeg ( angleindegrees )


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -