Loading the cannon with a bubble

First, we have to load the cannon with a bubble.

The idea: Create a bubble and place it into the cannon.

The development: We need a variable to create a bubble_mc instance, so add bubble class level variable.

private const ROT_SPEED:uint=2;
private const R:uint=18;
private const D:Number=R*Math.sqrt(3);
private var cannon:cannon_mc;
private var left:Boolean=false;
private var right:Boolean=false;
private var bubCont:Sprite;
private var bubble:bubble_mc;

Once the container has been drawn and the cannon has been placed, we can place the bubble. Delegate it to loadBubble function in Main constructor.

public function Main() { placeContainer(); placeCannon(); loadBubble(); stage.addEventListener(KeyboardEvent.KEY_DOWN,onKDown); ...

Get Flash Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.