Ok, this might get dizzy so sit down and bare with me please.
My game has 50 levels and 3 difficulty modes, so I use an array to store the score for width(51):LevelNumber and height(4):Difficulty(I use 51 and 4 becaue I don't want to store at 0,0). "LevelNumber" and "Difficulty" are global variables.
We have 3 layouts:
- Main: where you have start game, options, quit, etc. (this is where the game boots up)
- LevelSelector: where you choose what level you want to play and the difficulty (you are taken here when you press "Start Game" on the main layout)
- Level 1: the first level of the game
Now on the LevelSelector I have sprites for all the levels, each sprite has 4 spritefonts on it as follows: first spritefont-the level name, second spritefont-"Easy: ", third spritefont-"Medium: " and forth spritefont-"Hard: " . The layout olso has 2 list objects, one to select your level and another to select your difficulty and another sprite(button) when you press it, it takes you to the selected level and difficulty and sets the global variables for those.
So you play a level(all levels share the same event sheet) and at the end of the level I have event: If the array value at(LevelNumber,Difficulty) < Score then action set value at(LevelNumber, Difficulty) to Score.(score is another global variable)
The problem is that now when I come back to the LevelSelector layout, if I want to show those scores I have to create on start of layout a different action for each spritefont!!!!.... so 50 levels x 3 difficulty modes=150 actions....
Imagine on start of layout:
Level1Easy(a spritefont object) | Set text to "Easy: " &Array.At(1,1)
Level1Medium(a different spritefont object) | Set text to "Medium: " &Array.At(1,2)
Level1Hard | Set text to "Hard: " &Array.At(1,3)
Level2Easy | Set text to "Easy: " &Array.At(2,1)
Is there a way to make this retrieval easier without using soooo many actions? Idealy I would want at start of layout to read the variables LevelNumber and Difficulty(which have been set by the level you just played) and then modify the correct spritefont that is chosen based on the number of those variables.
So what do I do, create a second array for the spritefonts? But then how do I put objects in the correct place in the array without again having 150 events telling C2 what object corresponds to what value.....
I've been sitting starring at the screen for about 1 hour now and I can't figure this out.....
Maybe I am overthinking it? Does it even matter(performance wise on mobiles and tablets) if I have so many actions on a start of layout event requesting things? Cause if it's just a "cleaner code" issue I could live without it....