Match 3 Bubble Popper...

Hello,

I am trying to make a classic bubble popper where the entire board is full and the player must click on a group of at least 3 bubbles of the same color to make them pop… nothing fancy.

So I’m done with the logic that detects if there are at least 3 bubbles and makes the entire group invisible.

I’m struggling filling the spaces the popped bubbles leave behind…

The function below should ‘relocate’ the bubbles compressing them all to the bottom (I haven’t yet made new ones spawn at the top)  but what’s happening is that they only move one spot down and leave empty spaces.

local function relocateBubbles() --repeat destroyedBubbles=false for row = 12, 1, -1 do for column = 10, 1, -1 do if stage[row][column].destroyMe==1 then for myRow = row, 2, -1 do transition.to( stage[myRow-1][column], { time=1, y=(stage[myRow-1][column].y+32)}) stage[myRow][column].destroyMe = stage[myRow-1][column].destroyMe destroyedBubbles=true print("moved row: "..myRow) end end end end print("Just Looped") for row = 1, 12, 1 do --for column = 1, 10, 1 do print(stage[row][1].destroyMe.." "..stage[row][2].destroyMe.." "..stage[row][3].destroyMe.." "..stage[row][4].destroyMe.." "..stage[row][5].destroyMe.." "..stage[row][6].destroyMe.." "..stage[row][7].destroyMe.." "..stage[row][8].destroyMe.." "..stage[row][9].destroyMe.." "..stage[row][10].destroyMe) --end end --until destroyedBubbles==false --Reset Board Status markedNeighbors=0 for row = 1, 12, 1 do for column = 1, 10, 1 do stage[row][column].destroyMe=0 end end end

Any help will be greatly appreciated!

There is a really great prototype in the code exchange section where i’m pretty sure you’ll find the answers

http://developer.coronalabs.com/code/match-3-gems-puzzle-game-prototype

Yes, My first app was made with this script as a base, and I learned a lot (it is very well explained)

I think the trick is to make a for loop separately for the first row and then make the rest of the rows so that the uppermost row can fall down on the next. Your question is answered really well in the free code vlouchk mentioned 

Good luck

There is a really great prototype in the code exchange section where i’m pretty sure you’ll find the answers

http://developer.coronalabs.com/code/match-3-gems-puzzle-game-prototype

Yes, My first app was made with this script as a base, and I learned a lot (it is very well explained)

I think the trick is to make a for loop separately for the first row and then make the rest of the rows so that the uppermost row can fall down on the next. Your question is answered really well in the free code vlouchk mentioned 

Good luck