Drawing the game field with alternate rows

In odd rows, there can be only seven circles, shifted by R pixels on the right.

The idea: Check whether we are drawing an odd or an even row. Then if we are drawing an even row, draw circles in the same way you just drew, if we are drawing an odd row, shift circles' center by R pixels on the right and don't draw the last circle.

The development: Change placeContainer function this way:

private function placeContainer():void { bubCont=new Sprite(); addChild(bubCont); bubCont.graphics.lineStyle(1,0xffffff,0.2); for (var i:uint=0; i<11; i++) { for (var j:uint=0; j<8; j++) { if (i%2==0) { bubCont.graphics.drawCircle(R+j*R*2,R+i*R*2,R); } else { if (j<7) { with (bubCont.graphics) { drawCircle(2*R+j*R*2,R+i*R*2,R); ...

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.