Lớp công cụ
ImageLabel
*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.
Tóm Tắt
Thuộc Tính
Image:ContentId |
Tài Liệu Tham Khảo API
Thuộc Tính
Image
ImageLabel.Image:ContentId
ImageTransparency
Mẫu mã
Biến đổi độ trong suốt của hình ảnh
local RunService = game:GetService("RunService")
local imageLabel = script.Parent
local function onRenderStep()
-- Biến đổi độ trong suốt của hình ảnh từ 0 đến 1 bằng cách sử dụng sóng sine
imageLabel.ImageTransparency = math.sin(workspace.DistributedGameTime * math.pi) * 0.5 + 0.5
end
RunService.RenderStepped:Connect(onRenderStep)IsLoaded
Mẫu mã
Thời gian tải hình ảnh
local imageLabel = script.Parent
local startTime = workspace.DistributedGameTime
-- Chờ hình ảnh tải
while not imageLabel.IsLoaded do
task.wait()
end
-- Đo và hiển thị thời gian cần để tải
local deltaTime = workspace.DistributedGameTime - startTime
print(("Hình ảnh đã tải trong %.3f giây"):format(deltaTime))TileSize
Mẫu mã
Ví dụ về Kiểu Tỉ Lệ Hình Ảnh
local imageLabel = script.Parent
-- Đặt hình ảnh nguồn là một ổ khóa 64x64
imageLabel.Image = "rbxassetid://284402752"
imageLabel.BackgroundTransparency = 0
imageLabel.BackgroundColor3 = Color3.new(1, 1, 1) -- Trắng
imageLabel.ImageColor3 = Color3.new(0, 0, 0) -- Đen
local function resizeInACircle()
for theta = 0, 2, 0.02 do
imageLabel.Size =
UDim2.new(0, 100 + math.cos(theta * 2 * math.pi) * 50, 0, 100 + math.sin(theta * 2 * math.pi) * 50)
task.wait()
end
end
while true do
-- Kéo dài đơn giản chỉ kéo dài hình ảnh nguồn để phù hợp
-- với không gian của phần tử UI
imageLabel.ScaleType = Enum.ScaleType.Stretch
resizeInACircle()
-- Gạch nối sẽ hiển thị hình ảnh nguồn nhiều lần
-- đủ để lấp đầy không gian của phần tử UI
imageLabel.ScaleType = Enum.ScaleType.Tile
imageLabel.TileSize = UDim2.new(0, 64, 0, 64)
resizeInACircle()
-- Cắt sẽ biến hình ảnh thành một giao diện chín phần.
imageLabel.ScaleType = Enum.ScaleType.Slice
imageLabel.SliceCenter = Rect.new(30, 30, 34, 34)
resizeInACircle()
end