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 b
🤖 回答引擎: 前端Lua |
🕒 时间: 2026-05-02 14:43:30 |
👁️ 阅读: 5
你的代码思路是正确的,但根据浮生梦老师前端课程内容,`GUI:ActionFadeIn` 这个函数在前端库中并不存在,应该使用 `GUI:ActionFadeTo` 来实现淡入效果。
另外,序列帧动画结束后不显示,很可能是因为 `GUI:Frames_Create` 的参数 `ext` 中的 `finishhide` 没有设置。默认情况下,序列帧播放完可能会自动隐藏。你需要显式地设置 `finishhide = 0` 来确保播放结束后控件仍然可见。
以下是修正后的代码:
```lua
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 = 50, count = 35, loop = 1, finishhide = 0} -- 关键:设置 finishhide = 0
)
GUI:setAnchorPoint(fullScreenAnim, 0.5, 0.5)
GUI:setContentSize(fullScreenAnim, screenWidth, screenHeight)
GUI:setIgnoreContentAdaptWithSize(fullScreenAnim, false)
-- 创建动画结束回调
local function onAnimationComplete()
-- 在屏幕中心创建左侧序列帧
local leftAnim = GUI:Frames_Create(
parent,
"LeftFrames",
screenWidth/2 - 200, -- 左侧偏移200像素
screenHeight/2,
"res/yuding/tianshudonghua/citiao2/1/",
".png",
1,
10,
{speed = 80, count = 10, loop = 1, finishhide = 0} -- 同样设置 finishhide = 0
)
GUI:setAnchorPoint(leftAnim, 0.5, 0.5)
-- 在屏幕中心创建右侧图片(先设置透明度为0)
local rightImg = GUI:Image_Create(
parent,
"RightImage",
screenWidth/2 + 200, -- 右侧偏移200像素
screenHeight/2,
"res/yuding/tianshudonghua/mingzi/1.png"
)
GUI:setAnchorPoint(rightImg, 0.5, 0.5)
GUI:setOpacity(rightImg, 0) -- 初始透明
-- 执行淡入动画:使用 ActionFadeTo,参数为 (时间, 目标透明度)
GUI:runAction(rightImg, GUI:ActionFadeTo(1.0, 255))
end
-- 将回调动作添加到序列帧动画中
-- 注意:需要根据实际动画时间计算延迟
GUI:runAction(fullScreenAnim, GUI:ActionSequence(
GUI:DelayTime(3.5), -- 35帧 * 100ms = 3500ms = 3.5秒
GUI:CallFunc(onAnimationComplete)
))
```
**主要修改点:**
1. **序列帧参数**:在两个 `GUI:Frames_Create` 的 `ext` 表中都增加了 `finishhide = 0`,确保动画播放完毕后控件不会自动隐藏。
2. **淡入动画**:将 `GUI:ActionFadeIn(1)` 替换为 `GUI:ActionFadeTo(1.0, 255)`。`ActionFadeTo` 的第一个参数是时间(秒),第二个参数是目标不透明度(0-255,255为完全不透明)。
这样修改后,第一个全屏序列帧播放完应该能正常显示,并触发回调创建后续的左侧序列帧和右侧的淡入图片了。如果还有问题,记得检查一下你的图片资源路径是否正确哦!
← 返回问答库