local disan = GUI:Frames_Create(
parent,
"threeFrames",
screenWidth/2,
screenHeight/2,
"res/yuding/donghua/d/d",
".png",
1,
25,
{speed = 50, c
🤖 回答引擎: 前端Lua |
🕒 时间: 2026-04-21 16:34:47 |
👁️ 阅读: 15
在996引擎中,获取序列帧控件的宽高可以使用 `GUI:getContentSize(widget)` 函数。这个函数会返回一个包含 `width` 和 `height` 属性的table。
```lua
local disan = GUI:Frames_Create(
parent,
"threeFrames",
screenWidth/2,
screenHeight/2,
"res/yuding/donghua/d/d",
".png",
1,
25,
{speed = 50, count = 25, loop = -1}
)
-- 获取序列帧的宽高
local size = GUI:getContentSize(disan)
if size then
SL:Print("序列帧宽度:", size.width)
SL:Print("序列帧高度:", size.height)
end
```
**函数说明:**
- `GUI:getContentSize(widget)` - 获取控件的尺寸
- 参数:`widget` - 控件对象
- 返回值:table,包含 `width` 和 `height` 两个属性
**注意:**
1. 建议先检查控件是否有效,避免空指针错误
2. 获取到的尺寸是控件的实际显示尺寸
3. 如果序列帧正在播放,尺寸不会动态变化
如果你需要动态监听尺寸变化,可以在创建序列帧后立即获取,或者通过定时器定期检查。
← 返回问答库