Releasing a bubble
When the mouse or tap is released with a bubble selected, we need to follow these steps:
Check for matches
Remove matched bubbles
Drop down bubbles above the removed bubbles
Refill the board
We perform all these steps in the releaseBubble
function:
function releaseBubble(selectedBubble, pointer) { checkAndKillBubbleMatches(selectedBubble); removeKilledBubbles(); var dropBubbleDuration = dropBubbles(); game.time.events.add(dropBubbleDuration * 100, refillBoard); window.allowInput = false; window.selectedBubble = null; window.tempShiftedBubble = null; }
Here, you can see that we refilled the board with some timeout. We did it using the game.time.events.add
function. The first parameter is timed out for calling the second parameter, that function is to refill the board. We need to be sure that all the existing bubbles have dropped down. In the end of the function, you can see that we disabled input. We enable it only when the board has finished refilling...