Game Development Reference
In-Depth Information
function GameScene:collapseGrid ()
local function onGridCollapseComplete (sender)
local function onMatchedAnimatedOut (sender)
self:collapseGrid()
end
for i = 1, #self.allGems do
local gem = self.allGems[i]
local xIndex = math.ceil
((gem:getPositionX() - constants.TILE_SIZE * 0.5) /
(constants.TILE_SIZE + constants.GRID_SPACE))
local yIndex = math.ceil
((gem:getPositionY() - constants.TILE_SIZE * 0.5) /
(constants.TILE_SIZE + constants.GRID_SPACE))
self.gridGemsColumnMap[xIndex][yIndex] =
gem
self.grid[xIndex][yIndex] = gem.type
end
if (self.gridController:checkGridMatches ()
== true) then
--animate matched games
if (self.addingCombos == true) then
if (#self.gridController.matchArray >
3) then self.combos = self.combos +
(#self.gridController.matchArray - 3) end
end
self.gridAnimations:animateMatches
(self.gridController.matchArray, onMatchedAnimatedOut)
self:showMatchParticle
(self.gridController.matchArray)
self:setGemsScore(#self.gridController.matchArray *
constants.POINTS)
self:playFX("match.wav")
else
--no more matches, check for combos
if (self.combos > 0) then
--now turn random gems into diamonds
local diamonds = {}
local removeGems = {}
Search WWH ::




Custom Search