I need to be able to save onto the same global array a position on the X dimension so that I can lock levels on the level select screen until the player has beat the level before it.
:pacman::pacdot::pacdot:D:<:pacdot:
Printable View
I need to be able to save onto the same global array a position on the X dimension so that I can lock levels on the level select screen until the player has beat the level before it.
:pacman::pacdot::pacdot:D:<:pacdot:
You can use the Array object and just load the array file, change the value, and save it back. On the first frame it will need to be created for the first time if it doesn't exist.
I don't think you understand what I mean. Basically:
1. Global array with X dimension being 15 for 15 levels
2. Writes position on X dimension to show which levels have been beaten
3. Loads position on level select screen to lock/unlock levels
I'm encountering a difficulty with #2 as the event editor will not recognize the global array for me on frames other than the one that the array is on. Yes, I have selected global array. I need to know how to change the position of the X dimension from other frames.
Oh shoot, I'm such a n00b...
Array FILE, gotcha.
Except I don't. Could you give me a quick rundown of how to use that?
Making the array global only works until the player closes the game. So,to counteract this you need to have the array load/save a file.
Step 1: Make a global string "Array Filename" that will contain the filename of the array, such as progress.arr (any extension you want). This way you can just change the global value and it will reflect the change everywhere in your code.
Step 2: Using the File object on the first frame, check to see if the array file exists yet. If it doesn't, use your array object to save a no-levels-unlocked array for starters.
Step 3: After the above events on the first frame, load the array and see which levels are unlocked and display them.
Step 4: When they unlock a new level, load the array, mark the new level as unlocked, and then save the array back.
That should do it!
Thanks, you guys are real lifesavers! Now if I can only get this done in the next 2 days...
I have been trying working with Global values to unlock levels. I have the Global value change after each level so the next one is unlocked. The problem is that if the player clicks to replay the first level, it re-locks the unlocked levels.
I don't understand how the Global array works that you mentioned above, are there any examples? I have searched everywhere for tutorials from start to finish on this and I can't find anything.
Thanks :)