Although it's not necessary to literally "draw" the game field, doing it will help us to deal with this particular kind of tile-based game. We know we are dealing with hexagonal tiles, but since hexagons can be drawn inside a circle, we will simplify the script drawing circular tiles.
The idea: We will draw on the stage the circular tiles that will define the game field. This will make us see where bubbles should be placed.
The development: As usual we need a DisplayObject to act as a container for everything related to game field. A new class level variable called bubCont
will do this job:
private const ROT_SPEED:uint=2;
private const RADIUS:uint=18;
private var cannon:cannon_mc;
private var left:Boolean=false;
private var right:Boolean=false;
private var bubCont:Sprite;
Then the first thing Main
function has to do is placing the container. We'll delegate this task to a function called placeContainer
.
public function Main() {
placeContainer();
...
}
placeContainer...