I am currently making a game where players can make buildings. However, when i was playing with saving and loading i stubbled accross a weird problem. Objects save fine but when they are loaded they sort of go invisible. However when i check the data by calling all the buildings in the system to check their positions and their names everything looks fine so yeah im kinda confused :/ . One thing you might want to know before looking at the code, "buildings" is an Arraylist and takes three parameters, i.e. new Building(string, int, int);. Here is the code i use for saving and loading buildings:

Genius Coder doesn't realize that nobody can really help you with such issues. This is not a library usage bug, like LWJGL. This is the code you written buggy. This is only loading part. You might be doing something wrong in a different place entirely.

The problem might be that you're actually assigning values that you use for rendering ONLY after some kind of an event. But seriously, nobody can really help you.

PS

People should stop doing something, just because they think they can be the best at it. Like "Genius Coder". You obviously are not a genius and you will never be. I remember when I started playing Counter Strike 1.6 like when I was 10 years old, first time I connected to server, my username was "killer", even though I couldn't kill anyone. This seems like a thing that humans use to hide their weakness. In reality I was a noob at that game who couldn't do anything, so I used words to try to make an impression. You're doing the same here. I'm not blaming or anything, just something I noticed about human beings Ow just to add it, if you don't know what League Of Legends is, it is basically a match game (like CoD) where you play matches about 30 minutes or something. You can play a lot of different characters. There are people who only "Main" 1 character and it is like they "think" they are good at it, because they "main" it. In reality, they are usually the worst player in the team.

Just something I would like to point out, I didnt choose my name my frined did so it cant be much of a weekness can it. I also realised that I had limited the code here, thats because I'm making a game to sell so I cant release a load of source code, anyway what would help you solve the problem. In other words what do you need to see?

The problem might be anywhere in your source code. ANYWHERE. From my little experience, I would suggest you look into constructors, type changes. You should first of all do a rough search for the bug. Meaning, don't stare at the same code for a long time. Just look if it has bugs or not, if not, check other parts of the code. Don't limit yourself to one area of the code. Just look at as much code as possible. BUGS ARE AT PLACES YOU DON'T EXPECT THEM TO BE. So just LOOK ANYWHERE. It is like "don't think, just do it".

Also, about the commercial thingy. Did you ever do a commercial project before?

Just something I would like to point out, I didnt choose my name my frined did so it cant be much of a weekness can it. I also realised that I had limited the code here, thats because I'm making a game to sell so I cant release a load of source code, anyway what would help you solve the problem. In other words what do you need to see?

Ok you shouldn't be trying to sell a game if you're new to game development. And even then releasing source code is the least of your issues. You can give us that snippet of code, or you can solve the problem by yourself. You're talking of invisible objects, but you're not even giving us the code that renders.

Ok you shouldn't be trying to sell a game if you're new to game development. And even then releasing source code is the least of your issues. You can give us that snippet of code, or you can solve the problem by yourself. You're talking of invisible objects, but you're not even giving us the code that renders.

Ok you shouldn't be trying to sell a game if you're new to game development. And even then releasing source code is the least of your issues. You can give us that snippet of code, or you can solve the problem by yourself. You're talking of invisible objects, but you're not even giving us the code that renders.

Sorry I expected you to sort of guess

1 2 3

for (Buildingc : Buildings) {c.draw(g2d); }

Yup cause we all have crystal balls here and we know what your draw method does

Seriously.. If this is your FIRST PROJECT, you should just share it with everyone for free. g2d probably means "graphics 2d" which means your game is probably shiet. If this is your FIRST COMMERCIAL PROJECT, make it free also, you will soon realize that nobody will buy your game. You can trust me on that one. I thought I was making the best game. 2 people bought it for 2EUROS each. I could call it a success. You need tremendous amount of work for people to enjoy it. You always need to put in 10 times more work than you're putting in.

Seriously.. If this is your FIRST PROJECT, you should just share it with everyone for free. g2d probably means "graphics 2d" which means your game is probably shiet. If this is your FIRST COMMERCIAL PROJECT, make it free also, you will soon realize that nobody will buy your game. You can trust me on that one. I thought I was making the best game. 2 people bought it for 2EUROS each. I could call it a success. You need tremendous amount of work for people to enjoy it. You always need to put in 10 times more work than you're putting in.

Im really not in the mood mate so if your not here to help with the problem like I have very kindly requested at the start of the thread then please leave and if i want to sell a game, whether it'll be a succes or not I honestly dont care

@Genius Coder Everyone here has been trying to help you. But you need to post more code. If you want help I recommend you actually listen to the people who are trying to help you, who are better at coding than you.

I don't know if I missed something, but this guy is just like the next clueless newbie, yet for some reason, he is getting flamed off the mark, just because of his username.

He's gotten the general response these people normally get (learn to debug, don't bother selling your first game, if you want help, give relevant source, etc.), but the attitude has been a lot... darker.

Shut the f**k up. Nobody tells someone that. Ever. How about I tell you that? You are a retard, a complete idiot, and you will never ever be the least bit smart. That didn't sound so great did it? Now I do not believe you are stupid, quite the opposite actually, but you need to think about how you would feel if when you first started programming someone told you that when you asked a question. Please do.

Excuse my language. I don't think it's acceptable for people to tell someone they are stupid or something of the like when they don't know them and just judge on what they first see. Please, next time think, "Will any good come out of me saying this or doing that?". Because saying that stuff just puts people down and makes you look like a dick.

Its just because its frustrating to see so many people assume they are all that, and assume that selling a game is very easy, and assume that he doesn't have to show code because he's going to be a big shot developer. Genius Coder, we've already seen all the code you've written. Not yours specifically, but I can bet you everyone on this thread has been programming for longer. Thinking that we can't see your code because you're going to sell it is ignorant and offensive.

Its just because its frustrating to see so many people assume they are all that, and assume that selling a game is very easy, and assume that he doesn't have to show code because he's going to be a big shot developer. Genius Coder, we've already seen all the code you've written. Not yours specifically, but I can bet you everyone on this thread has been programming for longer. Thinking that we can't see your code because you're going to sell it is ignorant and offensive.

Point taken, but I don't think that warrants a "You're not a genius and you won't ever be". And it is ignorant and offensive to think something like that, so he needs to learn that. I just hate when people tell somebody they can't do something that they totally can. That is ignorant and offensive as well.

Off topic: I don't think he is trolling. I saw the name and chuckled to myself, but lighten up guys, he's just like every other person on this forum, a programmer, who happens to be asking for suggestions/help.I don't think his name warrants the amount of abuse he has copped from certain members here.So I say let's stay on topic, stop the flaming, and try and help out, without being condescending.

On topic:I, myself am no expert on loading/saving...in fact, I've just popped back onto the forums are a while of no programming, and first thing I have asked about is saving/loading

While I am not great with the syntax of saving and loading, the concept behind it is pretty straight forward. Just like storing food in the fridge so you can eat it later.

Just like everyone else has said so bluntly here, you haven't posted the core rendering code that may present the problem, and I understand it may be a problem for you if you wish to sell your game. But remember, most of the people who are able to provide you with help, are people who actually have made games themselves, or are more experienced programmers who have been programming for years on end, refining and expanding their own programming knowledge...one way to help learn programming is to share your existing knowledge with others, hence why forums like this exist. So my point is, you probably shouldn't worry too much about people stealing your code....generally people who have to steal your code, have no idea how to use it anyway You don't have to post the entire source, but in this case, your methods for rendering.

It sounds like you are loading the data into the game, object positioning and names etc are showing when called from within a List (I'm guessing that is what you are using to keep track of your entities?), but the objects themselves are not visually being rendered.This tells me that the objects obviously exist in your world, but the information loaded, is not being used to determine what textures to load in the location of your objects.You say that they work before saving, but not after loading.So it's a matter of follow the yellow brick road and see where the bump is that takes things off course. I would say that your object information is being loaded into a List or ArrayList, but the code that normally determines what textures to load where those objects are, is not using that information at runtime.It really is hard to tell without some sort of code snippet to show what is going wrong, and where. It sounds like something ridiculously simple, but it could also be ridiculously complicated and difficult if your code is poorly structured.

A possible debugging check would be to write a "dump" method that displays ALL the information held in the Buildings class. Then, compare before and after the saving/loading process.

Or use a step-debugger and inspection to verify this, by putting breakpoints before and after the load.

It is plausible that an inexperienced programmer might add a "transient" keyword on the suggestion of an IDE, if there were any unserializable objects held in the class being saved/loaded. If "transient" was used for any variables, the data held in them will not be restored in the load.

I agree, that's totally not warranted, but being ignorant is very annoying. I don't care who you are, not researching before you get into something makes you look foolish.

what are you on about not researched it, I have otherwise how else did i know how to write up the save and load method, i came here because it wasnt working properly not becaujse i wanted loads of source code!

I get an error here: for (int i = 0; i < AmountOfBuildings; i++) Object_Control.Buildings.add((Building)save.readObject());The system says: java.lang.ClassCastException: java.lang.Integer cannot be cast to items.Building

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org