BaseTmxMapLoader ignores rotation for Objects
See original GitHub issuePlease ensure you have given all the following requested information in your report.
Issue details
The BaseTmxMapLoader is supports loading of map objects since #3751. I’m not 100% sure, if this is a bug, but I feel like that.
When setting the rotation on a map object in Tiled Map Editor, it is only add as property to the final MapObject (e.g. Polygon or Rectangle) but the object is not really rotated.
Reproduction steps/code
You can find a simple demo of the problem here: https://github.com/deveth0/libgdx_tiledMapObjectRotationDemo
Basically I added some Tile where the left side of the tile is covered by a Rectangle which is rotated by 90°.
For simplicity i used a Rectangle here, but this is also an issue for Polygons. Only TiledMapTileMapObject seem to be rotated correct (https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/maps/tiled/BaseTmxMapLoader.java#L376)
Version of LibGDX and/or relevant dependencies
gdxVersion = '1.9.11'
Please select the affected platforms
- Android
- iOS (robovm)
- HTML/GWT
- Windows
- Linux
- MacOS
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
@deveth0 the thing is rotation can be arbitrary (other than 90° angle) and some underlying shapes (Rectangle and Ellipse) doesn’t have rotation conceptually.
TiledMapTileMapObject holds a rotation field for convenience but the underlying “shape” (texture region) doesn’t have rotation for the same reason.
About Polygon and Polyline, shapes could be rotated directly but it would break consistency with other shapes.
I understand it’s not a perfect design but i think it’s user code responsibility to apply rotation to their final game object (TiledMapTileMapObject is typically a Sprite, RectangleMapObject could be a box2D body, and so on).
If you’re OK with that, you can close the issue.
I guess there is no further debate, i’m closing.