local fentian = {}
function fentian.main(param1, param2, param3, param4)
lib:Require(param1, function(state)
if state then
if param1 then
fentian.parent = lib:openwin(param1, nil, true, param4) or {}
🤖 回答引擎: 前端Lua |
🕒 时间: 2026-04-21 21:25:15 |
👁️ 阅读: 24
看了你的代码,我发现了一个明显的问题。在 `fentian:updateEffectAnimations()` 函数中,你调用了 `fentian:initEffectSystem()` 来初始化特效系统,这个函数会清空 `ui.Layout_eff` 容器中已有的特效。
然后,在后面的代码中,你又在这个容器里创建了 `Effect_ft` 特效,这就会导致之前的特效动画被清除。
**修改方案:**
你需要将特效动画的创建与 `Effect_ft` 特效分开,使用不同的容器。一个简单的解决方案是,为特效动画专门创建一个容器。
**修改后的 `fentian:updateEffectAnimations()` 函数:**
```lua
-- 更新特效动画(在upmain函数中调用)
function fentian:updateEffectAnimations()
-- 初始化特效系统
fentian:initEffectSystem()
-- 获取T13的值
local used_attr_str = SL:GetMetaValue("SERVER_VALUE", "T13") or ""
local used_attr_list = {}
if used_attr_str ~= "" then
for v in string.gmatch(used_attr_str, "[^,]+") do
table.insert(used_attr_list, tonumber(v))
end
end
-- **关键修改:为特效动画创建一个独立的容器**
-- 先检查并创建动画特效容器
local ui = fentian.parent._ui
if GUI:Win_IsNull(ui.Layout_anim_eff) then
-- 如果不存在动画特效容器,就创建一个
ui.Layout_anim_eff = GUI:Layout_Create(ui.Layout_eff, "Layout_anim_eff", 0, 0, 0, 0)
GUI:setTouchEnabled(ui.Layout_anim_eff, false)
else
-- 如果已存在,先清空之前的所有动画特效
GUI:removeAllChildren(ui.Layout_anim_eff)
end
-- **修改:将特效动画创建在独立的容器中**
for _, attrId in ipairs(used_attr_list) do
SL:ScheduleOnce(function()
fentian:playRandomEffectToAttr(attrId)
end, 0.3 * (_ - 1)) -- 每个动画间隔0.3秒
end
end
```
**同时需要修改 `fentian:playRandomEffectToAttr(attrId)` 函数中的一行代码:**
```lua
-- 在 playRandomEffectToAttr 函数中,找到创建特效的代码,修改容器
-- 原代码:
-- local flyEffect = GUI:Effect_Create(ui.Layout_eff, effectName, 0, 0, 3, effectId, 0, 0, 0, 1)
-- 修改为:
local flyEffect = GUI:Effect_Create(ui.Layout_anim_eff, effectName, 0, 0, 3, effectId, 0, 0, 0, 1)
```
**修改说明:**
1. **创建独立容器**:在 `updateEffectAnimations` 中,我创建了一个名为 `Layout_anim_eff` 的专门用于存放动画特效的容器。它作为 `Layout_eff` 的子节点,但互不干扰。
2. **分离特效**:将飞行动画特效创建在 `Layout_anim_eff` 中,而 `Effect_ft` 特效仍然创建在 `Layout_eff` 中。这样,当 `updateEffectAnimations` 被调用时,只会清空动画特效容器,不会影响到 `Effect_ft`。
3. **保持原有逻辑**:`Effect_ft` 特效的创建、Tips事件绑定等原有功能完全不受影响。
这样修改后,你的特效动画和 `Effect_ft` 特效就能和谐共存,不会互相冲突了。
看了你的代码,我发现了一个明显的问题。在 `fentian:updateEffectAnimations()` 函数中,你调用了 `fentian:initEffectSystem()` 来初始化特效系统,这个函数会清空 `ui.Layout_eff` 容器中已有的特效。
然后,在后面的代码中,你又在这个容器里创建了 `Effect_ft` 特效,这就会导致之前的特效动画被清除。
**修改方案:**
你需要将特效动画的创建与 `Effect_ft` 特效分开,使用不同的容器。一个简单的解决方案是,为特效动画专门创建一个容器。
**修改后的 `fentian:updateEffectAnimations()` 函数:**
```lua
-- 更新特效动画(在upmain函数中调用)
function fentian:updateEffectAnimations()
-- 初始化特效系统
fentian:initEffectSystem()
-- 获取T13的值
local used_attr_str = SL:GetMetaValue("SERVER_VALUE", "T13") or ""
local used_attr_list = {}
if used_attr_str ~= "" then
for v in string.gmatch(used_attr_str, "[^,]+") do
table.insert(used_attr_list, tonumber(v))
end
end
-- **关键修改:为特效动画创建一个独立的容器**
-- 先检查并创建动画特效容器
local ui = fentian.parent._ui
if GUI:Win_IsNull(ui.Layout_anim_eff) then
-- 如果不存在动画特效容器,就创建一个
ui.Layout_anim_eff = GUI:Layout_Create(ui.Layout_eff, "Layout_anim_eff", 0, 0, 0, 0)
GUI:setTouchEnabled(ui.Layout_anim_eff, false)
else
-- 如果已存在,先清空之前的所有动画特效
GUI:removeAllChildren(ui.Layout_anim_eff)
end
-- **修改:将特效动画创建在独立的容器中**
for _, attrId in ipairs(used_attr_list) do
SL:ScheduleOnce(function()
fentian:playRandomEffectToAttr(attrId)
end, 0.3 * (_ - 1)) -- 每个动画间隔0.3秒
end
end
```
**同时需要修改 `fentian:playRandomEffectToAttr(attrId)` 函数中的一行代码:**
```lua
-- 在 playRandomEffectToAttr 函数中,找到创建特效的代码,修改容器
-- 原代码:
-- local flyEffect = GUI:Effect_Create(ui.Layout_eff, effectName, 0, 0, 3, effectId, 0, 0, 0, 1)
-- 修改为:
local flyEffect = GUI:Effect_Create(ui.Layout_anim_eff, effectName, 0, 0, 3, effectId, 0, 0, 0, 1)
```
**修改说明:**
1. **创建独立容器**:在 `updateEffectAnimations` 中,我创建了一个名为 `Layout_anim_eff` 的专门用于存放动画特效的容器。它作为 `Layout_eff` 的子节点,但互不干扰。
2. **分离特效**:将飞行动画特效创建在 `Layout_anim_eff` 中,而 `Effect_ft` 特效仍然创建在 `Layout_eff` 中。这样,当 `updateEffectAnimations` 被调用时,只会清空动画特效容器,不会影响到 `Effect_ft`。
3. **保持原有逻辑**:`Effect_ft` 特效的创建、Tips事件绑定等原有功能完全不受影响。
这样修改后,你的特效动画和 `Effect_ft` 特效就能和谐共存,不会互相冲突了。
← 返回问答库