cocos2dx 3.0 quick lua transition action

前端之家收集整理的这篇文章主要介绍了cocos2dx 3.0 quick lua transition action前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

transition = {}local actionManager = cc.Director:getInstance():getActionManager()

1) transition.newEasing(action,easingName,more)

action 动作对象 easingName 缓冲效果的名字 more 创建缓冲效果的参数return mixed ret

2) transition.create(action,args)action 动作对象 args(table) 参数表格对象return mixed

3)*transition.execte(target,action,args)t

arget cc.Node显示对象

action Action 动作对象

args table 参数表格对象{delay,easing,onComplete,time(执行需要的时间)}

return value:mixed1

easing:支持的缓动效果

backIn,backOut,backInOut

bounce,bounceIn,bounceOut,bounceInOut

elastic,elasticIn,elasticOut,elasticInOut

exponentialIn,exponentialOut

In,Out,InOut,rateaction,sineIn,sineOut,sineInOut

例子:等待1.0秒开始移动对象耗时1.5秒,使用backout效果 将对象移动到屏幕中央, 结束后执行回调函数 transition.execute(sprite,MoveTo:create(1.5,cc.p(display.cx,display.cy)),{

delay=1.0,

easing="backout",

onComplete=function()

print("move complete!")

end,})

4) transition.rotateTo(sprite,{rotate =180,time = 2})耗时2秒,将sprite旋转到 180 度

5) transition.moveTo(sprite,{x=display.cx,y=display.cy,time=}) transition.moveBy(sprite,{x=100,y=100,time=1})

6) transition.fadeIn(sprite,{time = 1.5}) 透明度从0逐渐变为255如果不改变透明度 使用transition.fadeTo()transition.fadeOut(sprite,{time = 1})

7) transition.scaleTo(sprite,{scale = 0.5,time=1.5})

8) transition.sequence({

cc.MoveTo:create(0.5,cc.p(200,200)),

cc.FadeOut:create(0.2),cc.DelayTime:create(0.5),

cc.FadeIn:create(0.3),

})

sprite:runAction(sequence)

9) 帧动画local frames = display.newFrames("Walk%04d.png",1,20)

local animation = display.newAnimation(frames,0.5/20)

sprite:playAnimationOnce(animation,true) 播放一次

sprite:playAnimationForever(animation) 循环播放

true:播放完成后自动清理帧动画

猜你在找的Cocos2d-x相关文章