Image Button
*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.
API 참조
속성
Hover Image
Image Button. Hover Image:ContentId
Image
Image Button. Image:ContentId
코드 샘플
이미지 호버 잠금
local imageLabel = script.Parent
-- 이 예제의 이미지는 64x64입니다
imageLabel.Size = UDim2.fromOffset(64, 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()Image Color3
코드 샘플
이미지 호버 잠금
local imageLabel = script.Parent
-- 이 예제의 이미지는 64x64입니다
imageLabel.Size = UDim2.fromOffset(64, 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()Image Rect Offset
코드 샘플
스프라이트 시트를 사용한 이미지 애니메이션
-- 크기가 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
endImage Rect Size
코드 샘플
스프라이트 시트를 사용한 이미지 애니메이션
-- 크기가 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
endIs 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))Pressed Image
Image Button. Pressed Image:ContentId