--自定义框体特效
local cur_effId
if itemData and itemData.sDivParam2 then
for key, value in pairs(custCfg.matchEffCfg) do
if string.find(itemData.sDivParam2, key) then
cur_effId = value
break
```lua
--自定义框体特效
local cur_effId -- 声明当前特效ID变量
if itemData and itemData.sDivParam2 then -- 如果物品数据存在且sDivParam2字段存在
for key, value in pairs(custCfg.matchEffCfg) do -- 遍历匹配特效配置表
if string.find(itemData.sDivParam2, key) then -- 在sDivParam2中查找匹配的关键字
cur_effId = value -- 找到匹配的特效ID
break -- 跳出循环
end
end
if cur_effId then -- 如果找到了特效ID
if type(cur_effId) == "table" then -- 如果特效ID是表类型(多个特效随机)
local rand = cur_effId[math.random(#cur_effId)] -- 随机选择一个特效ID
cur_effId = nil -- 清空原变量
cur_effId = rand -- 赋值随机特效ID
end
local custPosCfg = custCfg.posCfg -- 获取位置配置表
local cont = GUI:getContentSize(parent) -- 获取父节点内容尺寸
local point = { x = cont.width / 2, y = cont.height / 2 } -- 计算中心点坐标
local ancY = 0.5 -- 默认锚点Y值(中心)
local posY = point.y -- 默认Y坐标(中心点)
local contH = cont.height -- 默认高度为父节点高度
if custPosCfg[cur_effId].istop then -- 如果配置中标记为顶部特效
ancY = 1 -- 锚点设为顶部
posY = GUI:getPosition(parent).y -- 位置设为父节点的Y坐标
end
local eff = GUI:Frames_Create(parent, "img_frames", point.x, posY, -- 创建帧动画特效
"res/custom/common/frame/tips/tx" .. cur_effId .. "_", -- 特效图片路径前缀
".png", 1, 20, { -- 图片后缀,起始帧,总帧数,配置参数
count = custPosCfg[cur_effId].imgCount, -- 图片数量
speed = custPosCfg[cur_effId].speed, -- 播放速度
loop = -1, -- 循环播放(-1表示无限循环)
finishhide = 1 -- 播放完成后隐藏
})
if custPosCfg[cur_effId].istop then -- 如果是顶部特效
contH = GUI:getContentSize(eff).height -- 高度设为特效自身高度
end
GUI:setAnchorPoint(eff, 0.5, ancY) -- 设置特效锚点
GUI:setContentSize(eff, cont.width, contH) -- 设置特效内容尺寸
GUI:setScaleX(eff, custPosCfg[cur_effId].scaleX) -- 设置X轴缩放
GUI:setScaleY(eff, custPosCfg[cur_effId].scaleY) -- 设置Y轴缩放
GUI:setPosition(eff, -- 设置特效位置(带偏移)
GUI:getPositionX(eff) + custPosCfg[cur_effId].offsetX,
GUI:getPositionY(eff) + custPosCfg[cur_effId].offsetY)
GUI:setOpacity(eff, custPosCfg[cur_effId].opac) -- 设置特效透明度
if custPosCfg[cur_effId].isInner and custPosCfg[cur_effId].bgOpac then -- 如果是内部特效且有背景透明度
GUI:setLocalZOrder(eff, -1) -- 设置渲染层级在背景之后
GUI:setOpacity(ItemTips.isTipsPanel, custPosCfg[cur_effId].bgOpac) -- 设置背景面板透明度
end
ItemTips.isTipsPanel = SL:CopyData(ItemTips.isTipsPanel) -- 复制面板数据(注:此函数在知识库中未找到,可能为自定义或底层函数)
end
end
-- 框体特效
local frameTopDesc = itemDescs.frame_top_desc -- 获取顶部描述数据
if frameTopDesc and next(frameTopDesc) then -- 如果顶部描述存在且不为空
local frameChilds = {} -- 创建子控件表
addFrameDesc(frameTopDesc, frameChilds) -- 添加描述到子控件表(注:addFrameDesc函数在知识库中未找到)
local tipsPanelSz = GUI:getContentSize(parent) -- 获取提示面板尺寸
for i, children in ipairs(frameChilds) do -- 遍历所有子控件
if children then -- 如果子控件存在
local x = GUI:getPositionX(children) -- 获取子控件X坐标
local y = GUI:getPositionY(children) + tipsPanelSz.height -- 计算新的Y坐标(向下偏移面板高度)
GUI:setPosition(children, x, y) -- 设置子控件新位置
animScale(children) -- 执行缩放动画(注:animScale函数在知识库中未找到)
end
end
end
local frameBottomDesc = itemDescs.frame_bottom_desc -- 获取底部描述数据
if frameBottomDesc then -- 如果底部描述存在
local frameChilds = {} -- 创建子控件表
addFrameDesc(frameBottomDesc, frameChilds) -- 添加描述到子控件表
for i, children in ipairs(frameChilds) do -- 遍历所有子控件
if children then -- 如果子控件存在
animScale(children) -- 执行缩放动画
end
end
end
```