Game Development Reference
In-Depth Information
function GridAnimations:animateMatches (matches,
onComplete)
local function onCompleteMe (sender)
self.animatedMatchedGems =
self.animatedMatchedGems - 1;
if (self.animatedMatchedGems == 0) then
if (onComplete ~= nil) then onComplete()
end
end
end
self.animatedMatchedGems = #matches
local gem = nil
for i, point in ipairs(matches) do
gem =
self.gameLayer.gridGemsColumnMap[point.x] [point.y]
gem:stopAllActions()
local scale = cc.EaseBackOut:create (
cc.ScaleTo:create(0.3, 0))
local callback =
cc.CallFunc:create(onCompleteMe)
local action = cc.Sequence:create (scale,
callback)
gem.gemContainer:runAction(action)
end
end
This will scale down a gem to nothing, and only fire the final callback when all
gems have finish scaling.
4. Next is the collect diamonds animation:
function GridAnimations:collectDiamonds(diamonds)
local function removeDiamond (sender)
sender:setVisible(false)
end
for i = 1, #diamonds do
local delay = cc.DelayTime:create(i * 0.05)
local moveTo = cc.EaseBackIn:create(
cc.MoveTo:create ( 0.8, cc.p(50,
constants.SCREEN_HEIGHT - 50) ) )
Search WWH ::




Custom Search