local ui = {}
function ui.init(parent)
-- Create tipsLayout
local tipsLayout = GUI:Layout_Create(parent, "tipsLayout", 265.00, 400.00, 135.00, 173.00, false)
GUI:Layout_setBackGroundImageScale9Slice(tipsLayout, 44, 44, 57, 57)
GUI:Layout_setBackG
🤖 回答引擎: 前端Lua |
🕒 时间: 2026-04-15 14:27:50 |
👁️ 阅读: 6
这个序列帧不会动,可能是因为创建时缺少了播放动作。根据浮生梦老师前端课程内容,创建序列帧动画后需要手动调用播放函数。
检查你的代码,发现创建后没有启动动画。需要添加播放动作:
```lua
local ui = {}
function ui.init(parent)
-- Create tipsLayout
local tipsLayout = GUI:Layout_Create(parent, "tipsLayout", 265.00, 400.00, 135.00, 173.00, false)
GUI:Layout_setBackGroundImageScale9Slice(tipsLayout, 44, 44, 57, 57)
GUI:Layout_setBackGroundImage(tipsLayout, "res/xixi/zhuangbeikuang/jichu.png")
GUI:setChineseName(tipsLayout, "物品展示布局")
GUI:setAnchorPoint(tipsLayout, 0.00, 1.00)
GUI:setTouchEnabled(tipsLayout, false)
GUI:setTag(tipsLayout, -1)
local ext = {
count = 20,
speed = 100,
loop = -1,
finishhide = 1,
}
local frames = GUI:Frames_Create(tipsLayout, "frames", 0, 0, "res/xixi/xuliezhen2/", ".png", 1, 20, ext)
-- 添加播放动作
GUI:runAction(frames, GUI:ActionRepeatForever(GUI:ActionFrames(1, 20, 100, 20)))
end
return ui
```
主要问题:
1. `GUI:Frames_Create` 只是创建序列帧对象,不会自动播放
2. 需要添加动作来播放序列帧动画
3. 使用 `GUI:ActionFrames()` 创建序列帧播放动作
4. 用 `GUI:ActionRepeatForever()` 实现循环播放
注意:`speed`参数在ext表中是创建时的配置,但播放时需要在动作中重新指定播放速度(毫秒)。
← 返回问答库