找回密码
 立即注册
    查看: 143|回复: 1

    【浮生梦】复合动作的几种用法

    [复制链接]

    324

    主题

    66

    回帖

    1458

    积分

    积分
    1458
    发表于 2025-4-6 05:01:46 | 显示全部楼层 |阅读模式

    复合动作

    ActionEaseBackIn(action) 加速度向右,反方向缓慢移动

    参数 必选 类型 注释
    action obj 动作对象

    先理解action是什么

    可执行的动作对象 几个特征
    继承cocos的基本动作 cc.Action
    包含时间 速度 目标节点等属性其中
    通过runAction() 绑定游戏对象

    EaseBackIn

    可实现攻击后退

    local parent = GUI:Attach_LeftBottom()
    
    local oldBtn = GUI:getChildByName(parent, "btn1")
    if oldBtn then
    GUI:removeFromParent(oldBtn)
    end
    
    local btn = GUI:Button_Create(parent, "btn1", 200, 500, "res/public_win32/zhunxing.png")
    if not btn then
    SL:Print("按钮创建失败")
    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("错误")
    end
    

    ActionEaseBackOut

    实现后摇 野蛮冲撞 冲锋等效果 ActionEaseBackOut

    local parent = GUI:Attach_LeftBottom()
    
    local oldBtn = GUI:getChildByName(parent, "btn1")
    if oldBtn then
    GUI:removeFromParent(oldBtn)
    end
    
    local btn = GUI:Button_Create(parent, "btn1", 300, 300, "res/public_win32/zhunxing.png")
    if not btn then
    SL:Print("按钮创建失败")
    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("错误")
    end
    

    眩晕震荡效果

    local parent = GUI:Attach_LeftBottom()
    
    local oldBtn = GUI:getChildByName(parent, "btn1")
    if oldBtn then
    GUI:removeFromParent(oldBtn)
    end
    
    local btn = GUI:Button_Create(parent, "btn1", 200, 500, "res/public_win32/zhunxing.png")
    if not btn then
    SL:Print("按钮创建失败")
    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)
    
    
    

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x

    0

    主题

    0

    回帖

    -40

    积分

    积分
    -40
    发表于 2025-4-25 16:31:18 | 显示全部楼层
    哈哈,看来你对复合动作研究得很深入啊!让我用最幽默的方式给你总结一下这些酷炫的动作效果:

    1. ActionEaseBackIn - 就像被人打了一拳后退的效果,适合做攻击后摇
    1. local easeAction = GUI:ActionEaseBackIn(moveAction)
    复制代码

    2. ActionEaseBackOut - 野蛮冲撞必备!冲出去还能优雅地弹回来
    1. local easeAction = GUI:ActionEaseBackOut(moveAction)
    复制代码

    3. 眩晕震荡效果 - 被打得眼冒金星的感觉
    1. local easeDizzy = GUI:ActionEaseElasticIn(
    2.     GUI:ActionSpawn({rotateAction, shakeAction})
    3. )
    复制代码

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

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

    PS:下次可以试试把这些效果用在技能释放上,绝对能让你的游戏酷炫到飞起!
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则