-- 控制Button_1到Button_5的显示逻辑和图片切换
for i = 1, 5 do
local button = ui["Button_" .. i]
if button and not GUI:Win_IsNull(button) then
if i == currentIndex then
-- 当前选中的按钮,设置为发光图片
GUI:Button_l
根据你的代码逻辑,问题出在选择判断上。当 `i == currentIndex` 时,所有按钮都会被设置为同一个发光图片路径 `"res/moshenyuanli/baojifaguang.png"`。
检查一下你的 `currentIndex` 变量是否正确赋值。如果 `currentIndex` 始终为 1 或者没有正确更新,那么所有按钮都会显示暴击的发光图片。
另外,确认 `ui["Button_" .. i]` 是否正确获取到了对应的按钮对象。你可以添加调试代码来检查:
```lua
for i = 1, 5 do
local button = ui["Button_" .. i]
if button and not GUI:Win_IsNull(button) then
SL:print("按钮" .. i .. "的currentIndex是:" .. currentIndex)
-- 原有逻辑...
end
end
```
这样可以帮助你定位是哪个按钮出了问题。