【发布时间】:2019-05-20 03:16:40
【问题描述】:
我正在 Roblox Studio 中制作主菜单。当我按下播放时,它会向下移动,但背景不会淡出。
这是我的代码:
--Define variables
local button = script.Parent
local frame = button.Parent
local function fadeOut(object)
for newTrans = 0, 1, 0.1 do
wait(0.1)
object.BackgroundTransparency = newTrans
end
end
button.MouseButton1Click:Connect(function()
--Get positions
local xScale = button.Position.X.Scale
local yScale = -1
local xOffset = button.Position.X.Offset
local yOffset = button.Position.Y.Offset
--New position
local newPos = UDim2.new(xScale, xOffset, yScale, yOffset)
--Indicate when the tweening is finished
local done = false
local function ended()
done = true
end
--Tween button
button:TweenPosition(newPos, "Out", "Quad", 1, true, ended)
--Wait for tweening
repeat
wait(0.1)
until done
--Fade out the frame
fadeOut(frame)
end)
淡出的代码在顶部,上面写着:local function fadeOut(object)
在该函数中会发生淡出。
感谢您的提前,
杰西
【问题讨论】: