Slick Forums

Discuss the Slick 2D Library
It is currently Wed Jun 19, 2013 9:24 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Jul 07, 2011 10:37 am 
Offline

Joined: Thu Jul 07, 2011 10:07 am
Posts: 2
Hi,

I'm attempting to implement some very basic collision detection for my tiled map. I've created a new map in tiled with two tilesets (each containing one image, grass and rocks). I've first drawn some grass tiles, and then some rocks above them. I then right clicked on the rocks layer and set layer properties to blocked and true.

In my code I run the following nested for loop to build a two dimensional array of tiles that contain the blocked attribute.

Code:
for (int xAxis=0;xAxis<map.getWidth(); xAxis++)
        {
                     for (int yAxis=0;yAxis<map.getHeight(); yAxis++)
                     {
                         
                        int tileID = map.getTileId(xAxis, yAxis, 0);
                         String value = map.getTileProperty(tileID, "blocked", "false");
                         //System.out.println("value is " + value);
                         if (value.equalsIgnoreCase("true"))
                         {
                            System.out.println("tile id" + tileID + "is BLOCKED");
                             blocked[xAxis][yAxis] = true;
                         }
                     }
         }


However none of the tiles are ever detected as having the blocked attribute. I've confirmed the index of the layer rocks by calling getLayerIndex("rocks") however it still doesn't work.

I'd be extremely grateful for any suggestions as this is very very frustrating.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2011 10:10 am 
Offline

Joined: Thu Jul 07, 2011 10:07 am
Posts: 2
I wasn't aware that there was a distinction between setting properties for the individual tiles and the tileset, once I attached the value to the specific tile in the set it worked :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

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