Slick Forums

Discuss the Slick 2D Library
It is currently Thu Dec 13, 2018 1:25 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Jun 21, 2012 1:07 pm 
Offline

Joined: Mon May 07, 2012 11:36 pm
Posts: 93
Hi, I'm currently trying to get an objects position when you click on it. On my map, i have 1 object layer with about 7 objects on.

I'm currently getting the list of objects like this:

Code:
for (i = 0; i < map.getObjectCount(0); i++) {
         for (j = 0; j < map.getObjectCount(0); j++) {
            if (i == 0) {
               System.out.println("i: " + i + " name: " + map.getObjectName(i, j));
            }

         }
      }


The output for this is:

Code:
i: 0 name: TV
i: 0 name: Chair
i: 0 name: Sofa
i: 0 name: Picture
i: 0 name: Pot Plant
i: 0 name: Pot Plant
i: 0 name: Dining table and chairs

Which is entirely correct.

Now, the problem i'm getting is, how am i supposed to get the x and y of the objects and store them for use later? doing a similar loop for the getObjectX and getObjectY doesn't seem to be giving me anything.

Any help would be great! Thanks


Top
 Profile  
 
PostPosted: Sat Jul 21, 2012 11:30 pm 
Offline

Joined: Sun Jul 08, 2012 10:33 am
Posts: 27
hey, haven't worked with objectlayer yet but what do you actually mean by:
Quote:
doing a similar loop for the getObjectX and getObjectY doesn't seem to be giving me anything.

?

does it really return nothing or does it return smth but you dont know what to do with it?
because it should give you the x and y values of the object (dont know if they are the actual pixel coords or just the tile location).
maybe you have to calculate the pixel-x/y values with them (multiplying with the tile size)?

greets Khorne


Top
 Profile  
 
PostPosted: Sat Aug 04, 2012 1:25 pm 
Offline

Joined: Fri Aug 03, 2012 5:16 am
Posts: 4
Tried Using TiledMap::getObjectX() and objectY()? You could probably do this inside the same loop.

I've yet to use this class, but these methods uses the same params as TiledMap::getObjectName.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


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:  
cron
Powered by phpBB® Forum Software © phpBB Group