So I've been trying to make a game with save/load capability using a global array, but it is acting really strange. In every layout I have a copy of the same array with the "Global" flag on. The first layout is a main menu where the array is loaded from a file, or if New Game is selected, default values are set to it. In the second layout I have a simple game where you can touch a save point to save all data in the array to a file. But for some reason it is not saving the data properly. Here's a brief summary of what I'm doing:
1. In the first layout, I press the "New Game" button. This sets the values of the array to what they should be at the beginning of the game. Then it goes to the next layout.
2. In the second layout, I have a few counters that show the data in the array, and they show the correct values right now. I walk up to a save point and save the array to "leet.sav" in the game's directory. Then I restart the game.
3. I'm back at the first layout. I press the "Load Game" button and it checks to see if "leet.sav" exists, if that is true, it loads the data from that file and jumps to the next layout.
4. Now, when I'm in the second layout, all of the counters display 0. Zero.
What could be the cause of this? I'm not sure if it's the save or the load process that drops the values, but I cannot work any further until I fix this.
I have added a debug event that says "On key Z pressed: Array Set index (1,1) to index (1,1)+1". So when I press that button one of the counters is increased by 1. This number is displayed properly in the counter on the screen. I save the data and restart the app. When I go back and load the data, guess what? All the *other* counters are at zero, while the counter I increased has retained its added value, but lost the value it had before I started adding to it.