Removing the chain

Once we find a chain, bubbles in that chain have to be removed from the game field.

The idea: When we have a chain of three or more bubbles, we have to physically remove the bubbles and clear the corresponding elements in fieldArray array.

The development: We already have an array with all the bubbles to remove. Let's start calling bubbles in the same way when we create them. Add this line to parkBubble function:

private function parkBubble():void { var row:uint=Math.floor(bubble.y/D); var col:uint; if (row%2==0) { col=Math.floor(bubble.x/(R*2)); } else { col=Math.floor((bubble.x-R)/(R*2)); } var placed_bubble:bubble_mc = new bubble_mc(); bubCont.addChild(placed_bubble); if (row%2==0) { placed_bubble.x=(col*R*2)+R; } else { ...

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.