A better fix for the blank tiles after tile match bug:
The recommended fix above helps some of the time, but under certain annoying circumstances, it can still creep up. It looks like it’s related to stopping and restarting the FindNullTiles(), sometimes there will be a tile or two that wasn’t done yet, and when it restarts, for some reason it’s missing those…
So… what I did was encapsulate the entire function in a while loop… with the condition being “tilesareblank”… start with that as true… (we’re calling this because we know there are blank tiles, we made them). At the end of the function, I added a quick check for blank tiles. If there are no blank tiles, set tilesareblank to false, otherwise, set it to true.
All that good juicy code for finding blank tiles and scrolling
for (int x=0;x<xSize;x++)
My first clever attempt to fix this was to simply call the routine at the end of the routine… (i.e. just keep looking for nulls), but that led to a beautiful lockup…
Combined with the extra row of tiles, this appears to completely eliminate the missing tile bug.
I included a new int in board Manager yTop, during the creation phase, if y>yTop then I deactivate newTile’s collider. You could have 50 ySize and 11yTop and never get a match off screen. I also added a boolean PreventCascades. If true, this activates the code in the GetNewSprite(x,y) function that prevents matches. This allows for spawns to create those epic cascading matches you see in some games.
Next, I jiggered the code to cue up the tiles for clearing instead of clearing them outright. This eliminates some missed match opportunities where if both tiles would make a match, but the first tile’s matchup causes the tiles to start shifting before the 2nd tile’s match can be determined… I added a boolean “isMatched” instead of clearing the sprite. Then after checking for matches, I call a global function to null all sprites who have isMatched set, THEN call FindNullTiles.