aspose file tools*
The moose likes Beginning Java and the fly likes Can't figure out why my TMX loader won't work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can Watch "Can New topic
Author

Can't figure out why my TMX loader won't work

Fiona Heiss
Greenhorn

Joined: Jan 02, 2013
Posts: 5
Hey guys. I'm having trouble with a part of my project, specifically the TMX loader. More specifically, it appears that information is not being stored in variables correctly, or maybe I'm accessing them at the wrong time, I'm not sure which. I'll go through what's not working.

In my main game file, I do this in the render method of libgdx.



The "map" variable is null. I initialize this thusly:



then set it in the create method like this:



Here is the drawMap method:



And here is getTileSet:



In addition, the line "g2d.drawImage(scaledTile, x, y, null);" is never called, which makes me think "map" is null, but I can't figure out why...

I don't want to include all of the code on this forum, since that would make for quite a large post. So, I uploaded it below:

http://sdrv.ms/VTDtjP

I've spent quite awhile trying to figure out why it won't work, but I can't figure it out myself. I've never been good at thinking outside of the box, so someone else's viewpoint would be very helpful.

If someone can immediately spot something fishy, please tell me! If not, I'd really appreciate it if someone could take a look at my code, as I am completely stumped. Thank you very much for any help!

(I posted this on the libgdx forum, but it's not very active, so I thought I might get more help here, if that's fine)
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Fiona Heiss wrote:More specifically, it appears that information is not being stored in variables correctly

This sort of thing should not really cross your mind. Variables work in Java. Always look in your own code (until you get confirmation from outside).

or maybe I'm accessing them at the wrong time

That's what you should be looking for, it is the most likely scenario.

The "map" variable is null. I initialize this thusly:

How do you know it is null? Do you get a NullPointerException?

In addition, the line "g2d.drawImage(scaledTile, x, y, null);" is never called, which makes me think "map" is null, but I can't figure out why...

How do you know that method is never called? Have you tried println statements or running through a debugger? That method wouldn't get called if map was not null, but was empty as well. Have you checked the values in the Lists as you enter and access them to make sure they exist, are what you think they are, and produce the results that you expect?

Steve
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Fiona Heiss wrote:(I posted this on the libgdx forum, but it's not very active, so I thought I might get more help here, if that's fine)


That is okay, but could you post a link to the topic in the other forum here, and post a link in the other forum back to this thread so we all know who's working on it and what answers you receive?

Thanks,
Fiona Heiss
Greenhorn

Joined: Jan 02, 2013
Posts: 5
Will do!
 
Don't get me started about those stupid light bulbs.
 
subject: Can't figure out why my TMX loader won't work