Image Label
*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡。
概要
屬性
Image:ContentId |
API 參考
屬性
Image
Image Label. Image:ContentId
Image Transparency
範例程式碼
振盪圖像透明度
local RunService = game:GetService("RunService")
local imageLabel = script.Parent
local function onRenderStep()
-- 使用正弦波將 ImageTransparency 從 0 振盪到 1
imageLabel.ImageTransparency = math.sin(workspace.DistributedGameTime * math.pi) * 0.5 + 0.5
end
RunService.RenderStepped:Connect(onRenderStep)Is Loaded
範例程式碼
圖片加載時間
local imageLabel = script.Parent
local startTime = workspace.DistributedGameTime
-- 等待圖片加載
while not imageLabel.IsLoaded do
task.wait()
end
-- 測量並顯示加載所需的時間
local deltaTime = workspace.DistributedGameTime - startTime
print(("圖片加載時間為 %.3f 秒"):format(deltaTime))Tile Size
範例程式碼
圖片縮放類型示範
local imageLabel = script.Parent
-- 將源圖像設置為 64x64 的鎖頭
imageLabel.Image = "rbxassetid://284402752"
imageLabel.BackgroundTransparency = 0
imageLabel.BackgroundColor3 = Color3.new(1, 1, 1) -- 白色
imageLabel.ImageColor3 = Color3.new(0, 0, 0) -- 黑色
local function resizeInACircle()
for theta = 0, 2, 0.02 do
imageLabel.Size =
UDim2.fromOffset(100 + math.cos(theta * 2 * math.pi) * 50, 100 + math.sin(theta * 2 * math.pi) * 50)
task.wait()
end
end
while true do
-- Stretch 只是將源圖像拉伸以適應
-- UI 元素的空間
imageLabel.ScaleType = Enum.ScaleType.Stretch
resizeInACircle()
-- Tile 將多次渲染源圖像
-- 以填滿 UI 元素的空間
imageLabel.ScaleType = Enum.ScaleType.Tile
imageLabel.TileSize = UDim2.fromOffset(64, 64)
resizeInACircle()
-- Slice 將圖像轉換為九切片 UI。
imageLabel.ScaleType = Enum.ScaleType.Slice
imageLabel.SliceCenter = Rect.new(30, 30, 34, 34)
resizeInACircle()
end