local heinu = {}
function heinu.main(param1, param2, param3, param4)
lib:Require(param1, function(state)
if state then
if param1 then
heinu.parent = lib:openwin(param1, nil, true, param4) or {}
```lua
local heinu = {}
function heinu.main(param1, param2, param3, param4)
lib:Require(param1, function(state)
if state then
if param1 then
heinu.parent = lib:openwin(param1, nil, true, param4) or {}
heinu.param1 = param1
end
if param2 then
heinu.param2 = param2
end
if param3 then
heinu.param3 = param3
end
if heinu.parent.cfg and next(heinu.parent.cfg) then
heinu.upmain()
else
lib:msg("系统未配置!")
GUI:Win_Close(heinu.parent._parent)
end
end
end)
end
function heinu.playAnimation()
if not heinu.parent or not heinu.parent._ui then
return
end
local ui = heinu.parent._ui
-- 创建标题动画(淡入)
local titleImages = {ui.Image_9, ui.Image_10, ui.Image_11, ui.Image_12, ui.Image_13, ui.Image_14, ui.Image_15}
for _, img in ipairs(titleImages) do
if GUI:Win_IsNotNull(img) then
GUI:setOpacity(img, 0) -- 先设置为透明
GUI:setVisible(img, true)
GUI:runAction(img, GUI:ActionFadeTo(0.5, 255))
end
end
-- 1秒后执行黑煤球消失动画
SL:ScheduleOnce(function()
local coalImages = {ui.Image_2, ui.Image_3, ui.Image_4, ui.Image_5, ui.Image_6, ui.Image_7, ui.Image_8}
for i, img in ipairs(coalImages) do
if GUI:Win_IsNotNull(img) then
local delay = (i-1) * 0.1 -- 每个间隔0.1秒
local sequence = GUI:ActionSequence(
GUI:DelayTime(delay),
GUI:ActionMoveBy(0.5, 0, -100), -- 向下移动
GUI:ActionFadeTo(0.3, 0) -- 淡出
)
GUI:runAction(img, sequence)
end
end
end, 1.0)
end
function heinu.upmain()
if not heinu.parent or not heinu.parent._ui then
return
end
local ui = heinu.parent._ui
local var = tonumber(lib:getstr("U47") or 0)
SL:Print("获取当前焚天等级 var =", var)
if not GUI:Win_IsNull(ui.Text_1) then
GUI:Text_setString(ui.Text_1, (var or 0))
end
-- 重置所有图片状态
local allImages = {
ui.Image_9, ui.Image_10, ui.Image_11, ui.Image_12, ui.Image_13, ui.Image_14, ui.Image_15,
ui.Image_2, ui.Image_3, ui.Image_4, ui.Image_5, ui.Image_6, ui.Image_7, ui.Image_8
}
for _, img in ipairs(allImages) do
if GUI:Win_IsNotNull(img) then
GUI:setVisible(img, false)
GUI:setOpacity(img, 255) -- 重置透明度
GUI:stopAllActions(img) -- 停止所有动画
end
end
-- 根据等级显示对应图片
if var >= 1 then
GUI:setVisible(ui.Image_9, true)
GUI:setVisible(ui.Image_2, true)
end
if var >= 2 then
GUI:setVisible(ui.Image_10, true)
GUI:setVisible(ui.Image_3, true)
end
if var >= 3 then
GUI:setVisible(ui.Image_11, true)
GUI:setVisible(ui.Image_4, true)
end
if var >= 4 then
GUI:setVisible(ui.Image_12, true)
GUI:setVisible(ui.Image_5, true)
end
if var >= 5 then
GUI:setVisible(ui.Image_13, true)
GUI:setVisible(ui.Image_6, true)
end
if var >= 6 then
GUI:setVisible(ui.Image_14, true)
GUI:setVisible(ui.Image_7, true)
end
if var >= 7 then
GUI:setVisible(ui.Image_15, true)
GUI:setVisible(ui.Image_8, true)
end
-- 播放动画
heinu.playAnimation()
if GUI:Win_IsNotNull(ui.Button_1) then
GUI:addOnClickEvent(ui.Button_1, function()
SL:print("点击了第1个按钮")
GUI:delayTouchEnabled(ui.Button_1, 0.2)
local msg = {}
msg.Script = heinu.param1
local jsonstr = SL:JsonEncode(msg)
SL:SendLuaNetMsg(58003, heinu.param2, 0, 0, jsonstr)
end)
end
end
-- 注册游戏事件
SL:RegisterLUAEvent(LUA_EVENT_PLAYER_EQUIP_CHANGE, "heinu", function(data)
if data and data.opera == 1 then
heinu.upmain()
end
end)
SL:RegisterLUAEvent(LUA_EVENT_SERVER_VALUE_CHANGE, "heinu", function(data)
if next(data) and data.key == "U47" then
heinu.upmain()
end
end)
SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, "heinu", function(CLOSEWINdata)
if CLOSEWINdata and CLOSEWINdata == "heinu" then
SL:UnRegisterLUAEvent(LUA_EVENT_PLAYER_EQUIP_CHANGE, "heinu")
SL:UnRegisterLUAEvent(LUA_EVENT_SERVER_VALUE_CHANGE, "heinu")
SL:UnRegisterLUAEvent(LUA_EVENT_CLOSEWIN, "heinu")
end
end)
return heinu
```
**代码说明:**
1. **新增 `playAnimation()` 函数**:
- 标题图片(Image_9到Image_15)使用淡入动画(ActionFadeTo)
- 黑煤球图片(Image_2到Image_8)在1秒延迟后执行向下移动并淡出的组合动画
2. **修改 `upmain()` 函数**:
- 重置所有图片的可见性和透明度
- 停止之前的动画防止冲突
- 根据等级显示对应图片后调用动画函数
3. **使用的动画函数**:
- `GUI:ActionFadeTo(time, opacity)` - 淡入淡出效果
- `GUI:ActionMoveBy(time, deltaX, deltaY)` - 移动动画
- `GUI:ActionSequence(...)` - 组合多个动作顺序播放
- `GUI:DelayTime(duration)` - 延迟时间
- `SL:ScheduleOnce(callback, delay)` - 延迟执行函数
4. **动画效果**:
- 标题图片同时淡入显示
- 1秒后黑煤球依次向下移动消失(每个间隔0.1秒)
- 确保所有图片在播放动画前重置状态
注意:代码中修复了事件回调函数名从 `fentian.upmain()` 改为 `heinu.upmain()` 保持一致。