Do I need to have a different “You won” scene for each level? It looks like I can just have the same scene and it auto updates with the best time for what ever the last level played was, but I would need to have a button to select to play the next level on that screen. As well as a button that leads to a list of all unlocked levels they could select from.
So I also need to know how to make a scene that shows which levels are locked and which are unlocked.
Here an simple example, but obvious you don’t need make the exactly same thing like I did. It’s just for you can get the logic about global variable more easily.
Global variables can be accessed from any scene in the game!
I Created a “Level 5” scene and used a global variable type “boolean” (you can just choose TRUE or FALSE for that variable. Nothing more). So, when the boss is died I changed my global variable “Level 5 Completed?” to TRUE.
I created a scene with name “List of Levels” for player can choose what level he will play. Of course he can’t choose level 6 before he finished level 5. So, if Global Variable “Level 5 Completed?” is true the animation for “Level 6 button” will be “Open” and when he clicks on it… Level 6! Otherwise with variable “Level 5 Completed?” FALSE will be animation “Closed” and if he clicks on it nothing will happens.
Thanks for responding. With this method, would I need to have a boolean for each level within each level’s scene as in your first screen grab, and have one for each level on the “you won” screen the events you listed above in the second screen grab?
If I understand correctly: no. I created only one global variable “Level 5 Completed?” and changed it to TRUE. It can be accessed and changed from ANY scene in the game. So, in “List of levels” i checked it.
With my explanation you’ll need one global variable for each level.
Add as many instances of the LevelSelector to your scene as you have levels, and set the instance variable Level for each LevelSelector in the editor. If you like, you can add a button image behind each text object :
Yeah I did the same thing. It is good because you can use it as a level selection screen too. Also it is good for when you have more levels like over 10 and don’t want to clutter the scene that is shown after players win/beat levels.
I am leaning towards having a separate level selection page and on the “you won” page just having a “next level” button, and a “replay level” button along with a “all levels” button leading to the level selection page. I am hoping to have at least 20 levels to start with.
Thanks for catching that. I fixed it, but I’m still not getting a level to start when I click on any of the level text objects. The red or green. When I click on the highest level green one, the next red one turns green. And so on. I can get them all to eventually be green, but none send me to an actual level.
I tried loading from the opening title scene and play a full level just to make sure it wasn’t related to just loading the one scene.
HAHAHA! It’s my classic mistake. It just dawned on me (after reading what you wrote) that I called the levels “Level1” etc, not “level1”. Fixed the capital L, and now it works when I click on a level text object.
But, it didn’t unlock the third level when I finished Level2, it didn’t unlock level 3. Shouldn’t I have something that gets triggered at the end of each level to unlock the next? Maybe add the action you mentioned about the max level global variable to the same event that triggers the end of a level?
I tried putting that same action as mentioned above, but that didn’t work either.