Better Tiled support

Issue #8 new
Anonymous created an issue

I noticed not all Tiled's features are supported. Polygon objects being one of them. Also Slick throws an exception for objects that have no width or height attribute. I haven't fully explored all Tiled's features yet but I'll update if I find anything else.

Comments (2)

  1. Xiuhquiauitl

    Hey! In the game our team of three is on the way of creating we require the polygons for collisions, which led to the necessity to implement at least somewhat of a minimal support for them.

    The problem of the exception in case of lacking width & height can be easily corrected by not blindly parsing the strings, as trying to parse empty strings will give the exception.

    As for the polygons, they are stored in the .tmx file in an attribute of the element "polygon" like this:

    <polygon points="x1,y1 x2,y2 [...] xn,yn"/>

    After parsing this, splitting at the commas and spaces, we just convert the integer pixel-coords to tile-coords and store in an instance of slick.geom.Polygon, which in our case is stored directly in my class extending TiledMap for faster access, for more common usefulness you would probably store it in the GroupObject.

    If desired I can create a patch or fork for this.

  2. Log in to comment