Forums

ForumsProgramming Forum

programming levels

Posted Apr 11, '14 at 1:41pm

weirdlike

weirdlike

657 posts

Knight

I have seen some really creative ways online to programming levels in your game. They pretty much fall under 3 basic methods.

method 1:

Each level is on a frame, say the main screen is on frame 1 and you click to play level 3, the gotoAndStop function is executed and takes you to the frame level 3 is on (maybe frame 4).

pro's: very easy to understand and implement

con's: there must be code on each frame which puts a lot of extra effort on the programmer. Adding and removing listeners for each frame.

method 2:

Each level is a MovieClip on 1 frame, and are invisible. So when you click on level 3 the code then would make the menu visible = false, and then level 3 visible = true

pro's: all the code is programmed in 1 frame with only 1 loop and is easier to keep organized.

con's: for each level all the variables will need to be reset to correspond to the level, otherwise the objective for level 1 will be active while you are playing level 3 and might have conflicting errors, resulting in a very lengthy code, not to mention all the code will be loaded for each level and will create lag.

method 3:

Each level is a MovieClip and is not on the main timeline. If you click on a level to play, it will remove the screen, and then add the MovieClip containing the level.

pro's: The whole entire game is programmed in 1 function with only 1 loop, and specific parameters are loaded only when the MovieClip containing the level is loaded.

con's: While loading level 1 then moving on to level 2. Even after removing the MovieClip containing level 1, all the listeners that were present, still remain. So you will need to keep an eye on the listeners and remove them when they are no longer needed to keep the game play smooth with no lag.

All 3 of the methods work for both as2 and as3. There are a few other methods which I have not mentioned, like the method I use in as3, in which there is absolutely nothing on the main timeline and all the code is written externally in classes.

What method do you use?

 

Posted Apr 13, '14 at 3:25pm

mightybob

mightybob

367 posts

I use Scenes, so that when I want to make a new level I just click Duplicate Scene.

 

Posted Apr 13, '14 at 9:40pm

weirdlike

weirdlike

657 posts

Knight

I did that for a long time, works real good. Wasn't until I made the transition from programming in the actions panel to programming in classes that I haven't been doing it like that

 
Reply to programming levels

You must be logged in to post a reply!