设置序列帧尺寸
EquipmentTooltip = {}
-- 装备名字与序列帧路径的映射配置
EquipmentTooltip.frameSettings = {
-- 格式:装备名字 = {序列帧路径, 序列帧数量}
["圣战戒指"] = {"res/custom2/comm/itemeff/01/1_", 10},
-- 可以继续添加更多装备配置
}
-- 获取装备的序列帧配置
function EquipmentTooltip:getFrameConfig
🤖 回答引擎: 前端Lua |
🕒 时间: 2026-05-06 19:51:26 |
👁️ 阅读: 21
在浮生梦老师的前端课程中,设置序列帧的尺寸需要使用 `GUI:setContentSize` 函数。
根据你提供的代码,在创建序列帧后可以这样设置尺寸:
```lua
function EquipmentTooltip:createFrameAnimation(parent, ID, x, y, framePath, frameCount, width, height)
local ext = {
count = frameCount,
speed = 20,
loop = -1,
finishhide = 0 -- 播放结束不隐藏
}
local frameSprite = GUI:Frames_Create(
parent,
ID,
x,
y,
framePath,
".png",
1,
frameCount,
ext
)
-- 检查是否创建成功
if GUI:Win_IsNull(frameSprite) then
SL:Print("序列帧创建失败!")
return nil
else
SL:Print("序列帧创建成功")
-- 设置序列帧尺寸
GUI:setContentSize(frameSprite, width, height)
return frameSprite
end
end
```
**参数说明:**
- `frameSprite`:序列帧控件对象
- `width`:要设置的宽度(像素)
- `height`:要设置的高度(像素)
**使用示例:**
```lua
-- 创建圣战戒指的序列帧边框,尺寸为100x100
local frame = EquipmentTooltip:createFrameAnimation(
parentNode,
"frame_ring",
50, 50,
"res/custom2/comm/itemeff/01/1_",
10,
100, -- 宽度
100 -- 高度
)
```
这样就能在创建序列帧的同时设置其显示尺寸了。
← 返回问答库