Levels Menu
Now go to the next layout “levels” and lock “BG” layer (always check if BG is locked in all layouts) then delete buttons but keep the title.
Add the following sprites “level” and “Lock” with two animation: Default: “Locked” graphic & 2nd “unlocked” graphic (all the sprite names are found same in the graphic folder) then clone it as much levels u want (I’m using three in this tutorial so three is enough now)
Also Add Sprite call it “Stars” with animations: “Zero” Stars_zero, “One” Stars_one , “Two” Stars_two, “Three” stars_three.
Add instance variable for Level and name it ID. For each level add one to ID. ( example: level one’s id is 1 , level five’s id is 5, etc..)
Then add each “lock” Sprite to the top-right of the level.
Add Text , set font size to 100 (approximate to the level sprite size of 208, 173)
Then Add Buttons “Level_menu” menu , “Save” , “Load” at the bottom,-right of the layout.
The layout will look like this:
Coding
Now we need to prevent the player from playing locked levels & make him pass open and available levels. Also we will set animation to unlocked when the level is available.
We use everytick to set array at X=4 to level Value (you must change X array position for the last level. Example: Last level is 20, Level array is set to X=21)
And then also duplicate layout out but this time delete everything expect background & lock BG Layer.