ForumsProgramming ForumLocking and Unlocking levels

1 2649
Midmenj
offline
Midmenj
216 posts
Nomad

Hello again.... i have yet another question.

How do you lock and unlock levels in a game on Flash CS4 for AS 2.0.

I need the explanation in detail and where to put the codes and all that fun stuff. I would appreciate it a lot!

  • 1 Reply
PixelSmash
offline
PixelSmash
566 posts
Nomad

Allright... this is just from the top of my head, so don't hold me to it if it's not perfect.

What I suggest is perhaps an array of levels, which contain a boolean for the lock/unlock of that level.

if you want to use simple level indications (like 0, 1, etc) this could be an idea:

var levelArray:Array = new Array(true, false, true);

This would make level 0 unlocked, 1 locked, and 2 unlocked.
Locking/unlocking is pretty easy, if you want to lock level 2, simply say "levelArray[2]=false;"

If you want to use specific names for the levels (could be useful if you have a non-linear level structure) you could use most of the code above.

var levelArray:Array = new Array();
levelArray["home"] = true;
levelArray["outskirts"] = false;
levelArray["city"] = true;

...making 'home' and 'city' unlocked, and 'outskirts' locked. Locking/unlocking is the same as before... levelArray["outskirts"] = true;

Now that you've got the level array, you could make buttons for each level... I don't know the AS for it, but it could be something like this...

if(levelArray[1]){
create button at the desired location.
}

I hope this helps to get you on the right track! Good luck!

Showing 1-1 of 1