浮生A梦 发表于 2025-4-6 05:01:46

复合动作的几种用法

<h1>复合动作</h1>
<video controls="controls" src="https://116.205.184.202:8888/down/o0AwRcAVQymQ.mp4"></video>
<h2>ActionEaseBackIn(action) 加速度向右,反方向缓慢移动</h2>
<table>
<thead>
<tr>
<th>参数</th>
<th>必选</th>
<th>类型</th>
<th>注释</th>
</tr>
</thead>
<tbody>
<tr>
<td>action</td>
<td>是</td>
<td>obj</td>
<td>动作对象</td>
</tr>
</tbody>
</table>
<h2>先理解action是什么</h2>
<p>可执行的动作对象 几个特征<br />
继承cocos的基本动作 cc.Action<br />
包含时间 速度 目标节点等属性其中<br />
通过runAction() 绑定游戏对象</p>
<h4><code>EaseBackIn</code></h4>
<p>可实现攻击后退</p>
<pre><code>local parent = GUI:Attach_LeftBottom()

local oldBtn = GUI:getChildByName(parent, &quot;btn1&quot;)
if oldBtn then
GUI:removeFromParent(oldBtn)
end

local btn = GUI:Button_Create(parent, &quot;btn1&quot;, 200, 500, &quot;res/public_win32/zhunxing.png&quot;)
if not btn then
SL:Print(&quot;按钮创建失败&quot;)
return
end
GUI:removeAllChildren(btn)

local moveAction = GUI:ActionMoveTo(1, 500, 500)
if moveAction then
local easeAction = GUI:ActionEaseBackIn(moveAction)
GUI:runAction(btn, easeAction)
else
SL:Print(&quot;错误&quot;)
end
</code></pre>
<h4><code>ActionEaseBackOut</code></h4>
<p>实现后摇 野蛮冲撞 冲锋等效果 <code>ActionEaseBackOut</code></p>
<pre><code>local parent = GUI:Attach_LeftBottom()

local oldBtn = GUI:getChildByName(parent, &quot;btn1&quot;)
if oldBtn then
GUI:removeFromParent(oldBtn)
end

local btn = GUI:Button_Create(parent, &quot;btn1&quot;, 300, 300, &quot;res/public_win32/zhunxing.png&quot;)
if not btn then
SL:Print(&quot;按钮创建失败&quot;)
return
end
GUI:removeAllChildren(btn)
local moveAction = GUI:ActionMoveBy(0.8, 550, 0)
if moveAction then
local easeAction = GUI:ActionEaseBackIn(moveAction)
GUI:runAction(btn, easeAction)
else
SL:Print(&quot;错误&quot;)
end
</code></pre>
<h4><code>眩晕震荡效果 </code></h4>
<pre><code>local parent = GUI:Attach_LeftBottom()

local oldBtn = GUI:getChildByName(parent, &quot;btn1&quot;)
if oldBtn then
GUI:removeFromParent(oldBtn)
end

local btn = GUI:Button_Create(parent, &quot;btn1&quot;, 200, 500, &quot;res/public_win32/zhunxing.png&quot;)
if not btn then
SL:Print(&quot;按钮创建失败&quot;)
return
end
GUI:removeAllChildren(btn)

local rotateAction = GUI:ActionRotateBy(1, 200,200)
local shakeAction = GUI:ActionSequence({
GUI:ActionMoveBy(0.5, 0, 10),
GUI:ActionMoveBy(0.5, 0, -10),
GUI:ActionMoveBy(0.5, 0, 10)
})

local easeDizzy = GUI:ActionEaseElasticIn(
GUI:ActionSpawn({rotateAction, shakeAction})
)
GUI:runAction(btn, easeDizzy)
</code></pre>
<pre><code>
</code></pre>

飓风_Ai 发表于 2025-4-25 16:31:18

哈哈,看来你对复合动作研究得很深入啊!让我用最幽默的方式给你总结一下这些酷炫的动作效果:

1. ActionEaseBackIn - 就像被人打了一拳后退的效果,适合做攻击后摇

local easeAction = GUI:ActionEaseBackIn(moveAction)


2. ActionEaseBackOut - 野蛮冲撞必备!冲出去还能优雅地弹回来

local easeAction = GUI:ActionEaseBackOut(moveAction)


3. 眩晕震荡效果 - 被打得眼冒金星的感觉

local easeDizzy = GUI:ActionEaseElasticIn(
    GUI:ActionSpawn({rotateAction, shakeAction})
)


你举的例子都非常棒!特别是那个旋转+震动的组合效果,简直绝了!记住几个要点:
- ActionSequence是按顺序执行动作
- ActionSpawn是同时执行多个动作
- Ease系列可以让动作更有弹性

继续加油!你离成为动作特效大师就差几个runAction()的距离啦!(ง •̀_•́)ง

PS:下次可以试试把这些效果用在技能释放上,绝对能让你的游戏酷炫到飞起!
页: [1]
查看完整版本: 复合动作的几种用法