API 참조
속성
HoverImage
ImageButton.HoverImage:ContentId
Image
ImageButton.Image:ContentId
코드 샘플
이미지 호버 잠금
local imageLabel = script.Parent
-- 이 예제의 이미지는 64x64입니다.
imageLabel.Size = UDim2.new(0, 64, 0, 64)
local function unlock()
imageLabel.Image = "rbxassetid://284402785" -- 잠금 해제된 자물쇠 (64x64)
imageLabel.ImageColor3 = Color3.new(0, 0.5, 0) -- 진한 초록색
end
local function lock()
imageLabel.Image = "rbxassetid://284402752" -- 잠금된 자물쇠 (64x64)
imageLabel.ImageColor3 = Color3.new(0.5, 0, 0) -- 진한 빨간색
end
-- 이벤트 연결; 기본 상태는 잠금입니다.
imageLabel.MouseEnter:Connect(unlock)
imageLabel.MouseLeave:Connect(lock)
lock()ImageColor3
코드 샘플
이미지 호버 잠금
local imageLabel = script.Parent
-- 이 예제의 이미지는 64x64입니다.
imageLabel.Size = UDim2.new(0, 64, 0, 64)
local function unlock()
imageLabel.Image = "rbxassetid://284402785" -- 잠금 해제된 자물쇠 (64x64)
imageLabel.ImageColor3 = Color3.new(0, 0.5, 0) -- 진한 초록색
end
local function lock()
imageLabel.Image = "rbxassetid://284402752" -- 잠금된 자물쇠 (64x64)
imageLabel.ImageColor3 = Color3.new(0.5, 0, 0) -- 진한 빨간색
end
-- 이벤트 연결; 기본 상태는 잠금입니다.
imageLabel.MouseEnter:Connect(unlock)
imageLabel.MouseLeave:Connect(lock)
lock()ImageRectOffset
코드 샘플
스프라이트 시트를 사용한 이미지 애니메이션
-- 크기가 256x256인 ImageLabel/ImageButton에 이 코드를 배치하세요
local imageLabel = script.Parent
-- 다음 이미지는 1024x1024 크기에 12 프레임(256x256)입니다
-- 이 프레임은 사람의 펀치 애니메이션을 재생합니다
imageLabel.Image = "rbxassetid://848623155"
imageLabel.ImageRectSize = Vector2.new(256, 256)
-- 표시할 프레임의 순서 (좌에서 우, 그 다음 위에서 아래)
local frames = {
Vector2.new(0, 0),
Vector2.new(1, 0),
Vector2.new(2, 0),
Vector2.new(3, 0),
Vector2.new(0, 1),
Vector2.new(1, 1),
Vector2.new(2, 1),
Vector2.new(3, 1),
Vector2.new(0, 2),
Vector2.new(1, 2),
Vector2.new(2, 2),
Vector2.new(3, 2),
}
-- 프레임을 하나씩 루프에서 애니메이션으로 만듭니다
while true do
for _, frame in ipairs(frames) do
imageLabel.ImageRectOffset = frame * imageLabel.ImageRectSize
task.wait(0.1)
end
endImageRectSize
코드 샘플
스프라이트 시트를 사용한 이미지 애니메이션
-- 크기가 256x256인 ImageLabel/ImageButton에 이 코드를 배치하세요
local imageLabel = script.Parent
-- 다음 이미지는 1024x1024 크기에 12 프레임(256x256)입니다
-- 이 프레임은 사람의 펀치 애니메이션을 재생합니다
imageLabel.Image = "rbxassetid://848623155"
imageLabel.ImageRectSize = Vector2.new(256, 256)
-- 표시할 프레임의 순서 (좌에서 우, 그 다음 위에서 아래)
local frames = {
Vector2.new(0, 0),
Vector2.new(1, 0),
Vector2.new(2, 0),
Vector2.new(3, 0),
Vector2.new(0, 1),
Vector2.new(1, 1),
Vector2.new(2, 1),
Vector2.new(3, 1),
Vector2.new(0, 2),
Vector2.new(1, 2),
Vector2.new(2, 2),
Vector2.new(3, 2),
}
-- 프레임을 하나씩 루프에서 애니메이션으로 만듭니다
while true do
for _, frame in ipairs(frames) do
imageLabel.ImageRectOffset = frame * imageLabel.ImageRectSize
task.wait(0.1)
end
endIsLoaded
코드 샘플
이미지 로드 시간
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))PressedImage
ImageButton.PressedImage:ContentId