Jump to content
  • Advertisement
Sign in to follow this  
TheCrow33

[java] Saving Objects with Selective Information

This topic is 2572 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm developing a 3d world in java with opengl (perhaps eventually it will become a game) at the moment and I've made a Map class which is just a load of Tiles (simply a square on the floor). These tiles have Textures which are a global variable to the Tile class. So the problem is I want to load maps from a file, so at first I wrote a method for the map class that will parse a text file and load the Map accordingly, but for really big maps, the parsing is wicked slow. This is to be expected because disk read / write operations are wicked slow. So my next thought was to create another small program which will load the map from the text file and then save the object via implementing the Serializable class. My problem is that the Texture class, which the Tiles use to display images, is not Serializable.

So my question is, is there a way to have it skip that variable when it's saving the object? I may be losing my mind, but I could swear I covered doing this about a year ago in class and can't remember how to do it.

Share this post


Link to post
Share on other sites
Advertisement
Solved the problem with a quick and dirty approach. Just recompiled the Texture class of slick-util and made it serializable

Share this post


Link to post
Share on other sites
Use keyword transient, if you don't want a specific field to be serialized. Also since you are using Slick you can just use the implemented tile map loader, and create your maps in "Tiled" if you want to :)

Share this post


Link to post
Share on other sites
Yes! That was exactly the word I was looking for, I knew I hadn't lost my mind and imagined there was such a thing haha. Thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!