I was reading a tutorial about multiple levels, and the below really interested me on how i should go about this.
[COLOR=#4B5C77][FONT=Lucida Grande]It may seem natural to make one class per level, with each class extending AvoiderGame, and use events to switch between them. So, we might have classes named AvoiderGameLevelOne, AvoiderGameLevelTwo, etc., and let each one fire off a “NavigationEvent.NEXT_LEVEL” when appropriate. Presumably then the document class would listen for this event, and when it heard it, it would run “playScreen = new AvoiderGameLevelTwo()” (or whichever level was appropriate), and pass through all the information such as score and time to this new playScreen instance.[/FONT][/COLOR]
I’m not entirely sure on how to go about this. I put my stage, which is an array of tiles in a class called level1, level2, etc and had it extend my main class. Just to check if everything works, I added a public static var called levelArray in my main, which is a blank array. Then in level1, I pushed my array into levelArray.
So for my level1 class
package {
public class Level1 extends Main {
public var floor1:Array = new Array();
floor1[0] = [2,1,1,1,1,1,2];
floor1[1] = [1,1,1,1,1,1,1];
floor1[2] = [1,1,1,2,1,1,1];
floor1[3] = [1,1,1,1,1,1,1];
floor1[4] = [1,1,1,2,1,1,1];
floor1[5] = [1,1,1,1,1,1,1];
floor1[6] = [2,1,1,1,1,1,2];
public function Level1() {
Main.levelArray.push(floor1);
}
}
}
Doesn’t seem to be working. levelArray comes up as blank. Might be because the two classes aren’t communicating with each other correctly? Any ideas if I am approaching this the correct way?