How to lock&unlock levels & worlds

Hey, I was wondering how I could lock all the levels except 1, and that you will have you complete level 1 to continue for level 2.

Im using this level selection

http://www.newnams.com/corona-level-selection-tutorial/

but can someone help me add the lock & unlock into this.

Thanks
[import]uid: 134147 topic_id: 24589 reply_id: 324589[/import]

Given that tutorial: 3 worlds, 2 levels per world and using Storyboard. what I would do is this:

  1. Create a table and add it to the storyboard object that tracks the highest level for that world:
storyboard.highestLevel = {1, 0, 0}  

Now you want to let them have level 1 of world 1 unlocked.

In the code where you are drawing the whole world, you can do a simple check:

 if storyboard.highestLevel[thisWorld] == 0 then  
 -- the code to draw the world greyed out or however you want to show the world is locked  
 end  

In that example, substitue “thisWorld” with whatever variable is holding your current world ID.

Now for a world with unlocked levels you will do something similar.

Inside those nested “for” loops, between lines 36 and 37 I would add:

 if storyboard.highestLevel \>= current then  

then have the code to render the level and after line 43 add:

 else  
 levels[current] = -- some code to draw a greyed out button  
 end  

[import]uid: 19626 topic_id: 24589 reply_id: 99530[/import]

@speedy-boy Check this website made by Peach Pellen is exactly what you are looking for http://techority.com/2012/01/22/easy-level-unlocking-with-ego/

Read it carefully and I guarantee you will like it good luck

:slight_smile: [import]uid: 17058 topic_id: 24589 reply_id: 99620[/import]