Game Development Reference
In-Depth Information
self.animatedCollapsedGems + 1
local newY = gem:getPositionY()
- (drop - 1) * (constants.TILE_SIZE +
constants.GRID_SPACE)
self:dropGemTo (gem, newY, 0,
onComplete)
end
end
end
end
end
We loop through all the gems and identify the ones that have been scaled down,
meaning the ones which were removed . We move these above the column, so they
will fall down as new gems, and we pick a new type for them:
gem:setType ( self.gameLayer:getNewGem() )
The ones which were not removed will drop to their new positions. The way we
do this is simple. We count how many gems were removed until we reached a
gem which has not been removed. That count is stored in the local variable drop,
which is reset to 0 with every column.
That way, we know how many gems were removed below other gems. We use
that to find the new y position.
6. The dropGemTo new position looks like this:
function GridAnimations:dropGemTo (gem, y, delay,
onComplete)
gem:stopAllActions()
gem:reset()
local function onCompleteMe (sender)
self.animatedCollapsedGems =
self.animatedCollapsedGems - 1;
if ( self.animatedCollapsedGems == 0 ) then
if (onComplete ~= nil) then onComplete()
end
end
end
Search WWH ::




Custom Search