Creating Bloons in Flash
Tutorial parts
Part 6: Creating levels
Each level consists of two parts, a definition in our ActionScript and a MovieClip that is the actual level. The definition tracks properties like how many coins we need to get to complete a level and how many shots we have.
The Code
We begin with a simple definition of a level.
package Doubloons
{
public class Level
{
public var Clip:Class;
public var Shots:int;
public var CoinsToWin:int;
}
}
Because we need to restart levels all the time we define each level as a public static function. That means whenever we want "level1" we can just call Level.Level1();
These methods (one for each level) also go inside our Level class.
public static function Level1():Level
{
var level:Level = new Level();
level.Shots = 5;
level.CoinsToWin = 20;
level.Clip = Doubloons.Level1;
return level;
}
The MovieClips
You'll notice the property "Clip" in our level. This refers to a linked MovieClip from our library. Each "Clip" is a full level sitting in our FLA's library.
The levels in our FLA library
Each level clip is a complete level, we just put coins and anything else where we want them because the type is detected automatically back in our Game Loop from our Document class.
A level
That's it, nothing else to explain really. If it doesn't make sense yet grab the source, go through it, read through the tute again. There's a lot of things to keep track of but you'll get the hang of it as you start to see the big picture when you're looking at each component of it. Then you're ready to start building your own Bloons-style game!
Tutorial parts
Discuss
blog comments powered by DisqusPlay free games
Want to play free games? We recommend these games:
Sift Heads World - Act 3 Doodle Jump Online Doodle God Infectonator!: World Dominator When Penguins Attack When Penguins Attack 2 Original Blast Billiards Worm Madness Bloons Insanity Shadez 2 Cursed Treasure
