function diji(msgID, msgData)
local screenWidth = SL:GetMetaValue("SCREEN_WIDTH", 0)
local screenHeight = SL:GetMetaValue("SCREEN_HEIGHT", 0)
local parent = GUI:Win_Create("zhuanpan", 0, 0, screenWidth, screenHeight, false, false, true, false, fa
🤖 回答引擎: 前端Lua |
🕒 时间: 2026-05-02 14:33:30 |
👁️ 阅读: 4
你的代码有几个问题需要修复:
1. **序列帧回调问题**:`GUI:Frames_Create` 的 `ext` 参数中已经有 `loop = 1`,但你还用 `DelayTime` 计算时间,这样不可靠。应该使用 `GUI:Effect_addOnCompleteEvent` 来监听播放完成事件。
2. **动作执行时机**:`GUI:runAction` 需要在序列帧对象上执行,而不是创建一个新的动作序列。
3. **函数存在性检查**:`GUI:ActionFadeIn` 这个函数在知识库中不存在,应该使用 `GUI:ActionFadeTo`。
修正后的代码:
```lua
function diji(msgID, msgData)
local screenWidth = SL:GetMetaValue("SCREEN_WIDTH", 0)
local screenHeight = SL:GetMetaValue("SCREEN_HEIGHT", 0)
local parent = GUI:Win_Create("zhuanpan", 0, 0, screenWidth, screenHeight, false, false, true, false, false, false, 1)
-- 背景图片
local bg = GUI:Image_Create(parent, 'bg', 0, 0, 'res/yuding/tianshudonghua/1.png')
GUI:setContentSize(bg, screenWidth, screenHeight)
GUI:setAnchorPoint(bg, 0.5, 0.5)
GUI:setPosition(bg, screenWidth/2, screenHeight/2)
-- 全屏序列帧
local fullScreenAnim = GUI:Frames_Create(
parent,
"FullScreenFrames",
screenWidth/2,
screenHeight/2,
"res/yuding/tianshudonghua/fanshuzhen/a",
".png",
1,
35,
{speed = 100, count = 35, loop = 1}
)
GUI:setAnchorPoint(fullScreenAnim, 0.5, 0.5)
GUI:setContentSize(fullScreenAnim, screenWidth, screenHeight)
GUI:setIgnoreContentAdaptWithSize(fullScreenAnim, false)
-- 全屏序列帧结束后的回调函数
local function onFullScreenAnimFinish()
SL:print("全屏序列帧播放完成")
-- 左边序列帧(偏移200像素)
local leftAnim = GUI:Frames_Create(
parent,
"LeftFrames",
screenWidth/2 - 200,
screenHeight/2,
"res/yuding/tianshudonghua/citiao2/",
".png",
1,
10,
{speed = 100, count = 10, loop = 1}
)
GUI:setAnchorPoint(leftAnim, 0.5, 0.5)
GUI:setContentSize(leftAnim, 300, 300)
-- 右边图片
local rightImage = GUI:Image_Create(
parent,
'RightImage',
screenWidth/2 + 200,
screenHeight/2,
"res/yuding/tianshudonghua/mingzi/1"
)
GUI:setAnchorPoint(rightImage, 0.5, 0.5)
GUI:setContentSize(rightImage, 200, 200)
-- 设置初始透明度为0
GUI:setOpacity(rightImage, 0)
-- 执行淡入动作(使用ActionFadeTo)
GUI:runAction(rightImage, GUI:ActionFadeTo(1.0, 255))
end
-- 添加序列帧播放完成事件监听
GUI:Effect_addOnCompleteEvent(fullScreenAnim, onFullScreenAnimFinish)
end
```
**主要修改:**
1. 使用 `GUI:Effect_addOnCompleteEvent` 监听序列帧播放完成事件
2. 将 `GUI:ActionFadeIn(1)` 改为 `GUI:ActionFadeTo(1.0, 255)`(1秒淡入到不透明)
3. 添加了调试打印,方便查看播放状态
这样修改后,第一个序列帧播放完成后会自动触发回调函数,显示后面的内容。
← 返回问答库