Clase de motor
ImageLabel
*Este contenido se traduce usando la IA (Beta) y puede contener errores. Para ver esta página en inglés, haz clic en aquí.
Resumen
Propiedades
Image:ContentId |
Referencia API
Propiedades
Image
ImageLabel.Image:ContentId
ImageTransparency
Muestras de código
Oscilar la ImageTransparency
local RunService = game:GetService("RunService")
local imageLabel = script.Parent
local function onRenderStep()
-- Oscilar la ImageTransparency de 0 a 1 utilizando una onda sinusoidal
imageLabel.ImageTransparency = math.sin(workspace.DistributedGameTime * math.pi) * 0.5 + 0.5
end
RunService.RenderStepped:Connect(onRenderStep)IsLoaded
Muestras de código
Tiempo de Carga de Imagen
local imageLabel = script.Parent
local startTime = workspace.DistributedGameTime
-- Espera a que la imagen se cargue
while not imageLabel.IsLoaded do
task.wait()
end
-- Mide y muestra cuánto tiempo tomó cargar
local deltaTime = workspace.DistributedGameTime - startTime
print(("La imagen se cargó en %.3f segundos"):format(deltaTime))TileSize
Muestras de código
Demostración de ScaleType de Imagen
local imageLabel = script.Parent
-- Establecer la imagen de origen como un candado de 64x64
imageLabel.Image = "rbxassetid://284402752"
imageLabel.BackgroundTransparency = 0
imageLabel.BackgroundColor3 = Color3.new(1, 1, 1) -- Blanco
imageLabel.ImageColor3 = Color3.new(0, 0, 0) -- Negro
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
-- Stretch simplemente estira la imagen de origen para que se ajuste
-- al espacio del elemento de la UI
imageLabel.ScaleType = Enum.ScaleType.Stretch
resizeInACircle()
-- Tile renderizará la imagen de origen múltiples veces
-- lo suficiente para llenar el espacio del elemento de la UI
imageLabel.ScaleType = Enum.ScaleType.Tile
imageLabel.TileSize = UDim2.new(0, 64, 0, 64)
resizeInACircle()
-- Slice convertirá la imagen en una UI de nueve porciones.
imageLabel.ScaleType = Enum.ScaleType.Slice
imageLabel.SliceCenter = Rect.new(30, 30, 34, 34)
resizeInACircle()
end