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 {}
根据你提供的代码,我已经调整了动画部分。主要修改是确保Image_2到Image_8初始可见,并且动画顺序正确:
```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.upmain()
if not heinu.parent or not heinu.parent._ui then
return
end
local ui = heinu.parent._ui
local var = tonumber(SL:GetMetaValue("SERVER_VALUE", "U47"))
SL:Print("获取当前焚天等级 var =", var)
if not GUI:Win_IsNull(ui.Text_1) then
GUI:Text_setString(ui.Text_1, (var or 0))
end
-- 先隐藏所有Image_9到Image_15(感谢标题),显示Image_2到Image_8(黑煤球)
for i = 2, 8 do
local imgName = "Image_" .. i
if ui[imgName] and not GUI:Win_IsNull(ui[imgName]) then
GUI:setVisible(ui[imgName], true)
GUI:setOpacity(ui[imgName], 255)
end
end
for i = 9, 15 do
local imgName = "Image_" .. i
if ui[imgName] and not GUI:Win_IsNull(ui[imgName]) then
GUI:setVisible(ui[imgName], false)
GUI:setOpacity(ui[imgName], 0)
end
end
-- 根据var等级显示并执行动画
local function playAnimation(imgTitle, imgCoal, delayTime)
if not GUI:Win_IsNull(ui[imgTitle]) and not GUI:Win_IsNull(ui[imgCoal]) then
-- 感谢标题淡入动画
GUI:setVisible(ui[imgTitle], true)
local fadeInAction = GUI:ActionFadeTo(0.5, 255)
GUI:runAction(ui[imgTitle], fadeInAction)
-- 黑煤球1秒后向下移动并淡出
SL:ScheduleOnce(function()
local moveDown = GUI:ActionMoveBy(0.5, 0, -100)
local fadeOut = GUI:ActionFadeTo(0.5, 0)
local sequence = GUI:ActionSequence(moveDown, fadeOut)
GUI:runAction(ui[imgCoal], sequence)
end, 1.0 + delayTime)
end
end
-- 根据var等级执行动画
if var >= 1 then
playAnimation("Image_9", "Image_2", 0)
end
if var >= 2 then
playAnimation("Image_10", "Image_3", 0.1)
end
if var >= 3 then
playAnimation("Image_11", "Image_4", 0.2)
end
if var >= 4 then
playAnimation("Image_12", "Image_5", 0.3)
end
if var >= 5 then
playAnimation("Image_13", "Image_6", 0.4)
end
if var >= 6 then
playAnimation("Image_14", "Image_7", 0.5)
end
if var >= 7 then
playAnimation("Image_15", "Image_8", 0.6)
end
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. 将Image_2到Image_8初始设置为可见(`GUI:setVisible(ui[imgName], true)`)
2. 将Image_9到Image_15初始设置为不可见
3. 动画逻辑:先显示对应的感谢标题(淡入动画),1秒后对应的黑煤球向下移动并淡出
4. 保持了你的var等级判断逻辑
这样就能实现你想要的效果:根据焚天等级显示对应的感谢标题,1秒后对应的黑煤球向下消失。