Slick Forums

Discuss the Slick 2D Library
It is currently Sat Jan 18, 2020 4:59 pm

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Wed Jul 31, 2013 3:13 pm 

Joined: Tue Dec 11, 2012 3:21 pm
Posts: 1
The current TileDMap class does not support all features of the .tmx format (

I've already implemented some kind of support for polygons (note that I have no idea how the TileDMap class works, so my implementation might be inefficient. Maybe the class needs to be rewritten to make it efficient as a whole?)

Changes in

1.Add a field to store the polygon points to the GroupObject class
/** the properties of this group */
public Properties props;
public List<Point> polygonpoints;

2.Update the reading method in the constructor of GroupObject
         props.setProperty(name, value);
//read polygon points
Element polyElement = (Element) element.getElementsByTagName("polygon").item(0);
   String[] coordinates = polyElement.getAttribute("points").split("\\ ");
        //update the field
   polygonpoints = new ArrayList<Point>(coordinates.length);
        //and add the coordinates
   for(String coordinate:coordinates){
                //get the individual coordinates
      String[] point = coordinate.split(",");
      polygonpoints.add(new Point(Float.parseFloat(point[0]),Float.parseFloat(point[1])));

3.Add this method to the TileDMap class
* Get the list of polygon points of an object
* Returns null if there are no polygon points defined
public List<Point> getPolygonPoints(int groupID, int objectID){
   if (groupID >= 0 && groupID < objectGroups.size()) {
      ObjectGroup grp = (ObjectGroup) objectGroups.get(groupID);
      if (objectID >= 0 && objectID < grp.objects.size()) {
         GroupObject object = (GroupObject) grp.objects.get(objectID);
         return object.polygonpoints;
   return null;

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group