local action = cc.FadeOut:create(3)--淡出 local action = cc.FadeIn:create(3) -- 渐入 local action = cc.RotateBy:create(3.0,360) -- 旋转 local action = cc.ScaleTo:create(3,0.1) -- 缩放 cc.RepeatForever:create(某动作)--一个动作不断反复运行用
local rep1 = cc.Repeat:create(seq, 10)
精巧n秒,用DelayTime,使用方法例如以下:
cc.DelayTime:create(1.4)
多个动作的runAction
local sprite2 = cc.Sprite:create("img/equipment/background_root.png") sprite2:setPosition(cc.p(visibleSize.width/2, visibleSize.height/4)) mlayer:addChild(sprite2, 10) local action = cc.FadeOut:create(3)--淡出 local action2 = cc.FadeIn:create(3) -- 渐入 sprite2:runAction(cc.Sequence:create(action,action2,action))
sprite:runAction(cc.Spawn:create(cc.RotateBy:create(3.0,360),cc.ScaleTo:create(3,0.1)))
local screen = cc.Director:getInstance():getRunningScene() local action1 = cc.ScaleTo:create(0.5, 1) --放大 參数:时间和缩放尺寸 local action2 = cc.MoveTo:create(0.5, ccp(300,330)) --移动到某位置 local action3 = cc.ScaleTo:create(0.2, 0.6) --缩小 參数:时间和缩放尺寸 local action4 = cc.FadeOut:create(2)--淡出 local action5 = cc.MoveTo:create(2, ccp(300,450)) --移动到某位置 --复位 以便让动画反复 local action6 = cc.FadeIn:create(0.01)--渐入 local action7 = cc.MoveTo:create(0.01, ccp(300,300)) --移动到某位置 local sprite = cc.Sprite:create("fonts/number_green.png") sprite:setTextureRect(cc.rect(120, 0, 120, 28) ) sprite:setPosition(300,300) sprite:setAnchorPoint(ccp(0.5,0)) sprite:setScale(0.6) -- sprite:runAction(action1)--runAction运行一个动作 -- sprite:runAction(cc.Spawn:create(action1,action2))--cc.Spawn:create同一时候运行多个动作 -- sprite:runAction(cc.Sequence:create(cc.Spawn:create(action1,action2),action3,cc.Spawn:create(action4,action5)))--cc.Sequence:create循序运行多个动作 sprite:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.Spawn:create(action1,action2),action3,cc.Spawn:create(action4,action5),cc.Spawn:create(action6,action7))))--cc.RepeatForever:create(某动作)反复运行某个动作 screen:addChild(sprite)
action中回调方法cc.CallFunc:create()
local function removeThis()
ret:getParent():removeChild(ret, true)
Helper.nextAction()
end
--After 1.5 second, self will be removed.
ret:runAction( cc.Sequence:create(cc.DelayTime:create(1.4),cc.CallFunc:create(removeThis)))