--瞬时动作--Place 将节点放置到某个指定位置local place = cc.Place:create(cc.p(10,10))--FlipX FlipY 沿X或Y轴翻转显示local flipx=cc.FlipX:create(true)--Show Hide 显示和隐藏节点,如同设置节点的visible属性一样local hideAction = cc.Hide:create()--CallFunc 判断符合动作中某个动作是否执行结束并启动它的逻辑local callback =cc.CallFunc:create(function() print("hello") end)--有限时间动作--MoveTo MoveBylocal moveTo= cc.MoveTo:create(time,cc.p())--JumpTo JumpBylocal jumpTo = cc.JumpTo:create(time ,cc.p(),height,jumpsnumber)--BezierTo BezierBy 是节点沿贝塞尔曲线运动local action = cc.BezierTo:create(time,{cc.p(display.right,display.top),cc.p(200,200),cc.p(50,100)}) --[[ 参数1 时间 参数2 包含贝塞尔曲线数据的table,一次为:(1)控制点1,(2)控制点2,(3)BezierTo是目标终点,BezierBy是相对偏移量 ]]--ScaleTo ScaleBy 参数2 To是最终缩放系数,By是相对缩放系数local action = cc.ScaleTo:create(time,0.5)--RotateTo RotateBy 参数2 To是最终角度,By是相对旋转角度local rotate = cc.RotateTo:create(time,180)--Fadeln FadeOut FadeTo 淡入淡出local fadein = cc.FadeIn:create(time) local fadeto = cc.FadeTo:create(time,110) --参数2 目标透明度--TintTo TintBy 使节点着色local action = cc.TintTo:create(1,0,255,0) --[[ 参数1 To 目标red 值 By为相对red变化值 参数2 To 目标green 值 参数3 To 目标blue 值 ]] --Blink 闪烁 参数2 闪烁次数local blink = cc.Blink:create(time,2)--Animation 序列帧动画 display.addSpriteFrames(".plist",".png")local frames = display.newFrames(".png",1,14)local animation = display.newAnimation(frames,0.2)local animate = cc.Animate:create(animation)local sprite1 = display.newSprite("#xxx.png") :center() :addTo(self.backgroundLayer) :runAction(animate) -- 复合动作--DelayTime 延时动作cc.DelayTime:create(time)--Repeat RepeatForever 重复动作--Spawn 同时执行一批动作cc.Spawn:create(anction1,action2,...)--Sequence 同时并列执行cc.Sequence:create(anction1,action2,...)--Follow 使一个节点跟随另一个节点 参数1 跟随的目标 参数2 跟随范围cc.Follow:create(followedNode,rect)--示例function MainScene:ctor()self.background = display.newColorLayer(cc.c4f(128,128,128,255))self.background:addTo(self)local sprite1 = display.newSprite("1.png")sprite1:center()local move_left = cc.MoveBy:create(1.5,cc.p(display.width/2,0))local move_right = cc.MoveBy:create(3,cc.p(-display.width,0))local seq = cc.Sequence:create(seq)local rep = cc.RepeatForever:create(seq)sprite1:runAction(rep)sprite1:addTo(self.background)self.background:runAction(cc.Follow:create(sprite1)) end-- 变速动作
- --Speed 参数2 倍速
cc.Speed:create(action,speed)--ActionEase--[[In 先慢后快Out 先快后慢InOut 慢快慢]]cc.EaseSineIn:create(action)-- 节点与动作相关的接口Node:runAction(action)Node:stopAllActions()Node:stopAction(action)Node:stopActionByTag(tag)Node:setTag(tag)Action:setTag(tag)Node:getActionByTag(tag)