エンジンクラス
ImageLabel
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
プロパティ
Image:ContentId |
APIリファレンス
プロパティ
Image
ImageLabel.Image:ContentId
ImageTransparency
コードサンプル
振動する画像の透明度
local RunService = game:GetService("RunService")
local imageLabel = script.Parent
local function onRenderStep()
-- 0から1までの間でサイン波を使用してImageTransparencyを振動させる
imageLabel.ImageTransparency = math.sin(workspace.DistributedGameTime * math.pi) * 0.5 + 0.5
end
RunService.RenderStepped:Connect(onRenderStep)IsLoaded
コードサンプル
画像の読み込み時間
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))TileSize
コードサンプル
画像スケールタイプデモ
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.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
-- ストレッチはソース画像をUI要素のスペースに合わせて単純に引き伸ばします
imageLabel.ScaleType = Enum.ScaleType.Stretch
resizeInACircle()
-- タイルはソース画像を複数回レンダリングします
-- UI要素のスペースを埋めるのに十分な回数
imageLabel.ScaleType = Enum.ScaleType.Tile
imageLabel.TileSize = UDim2.new(0, 64, 0, 64)
resizeInACircle()
-- スライスは画像を9スライスのUIに変換します。
imageLabel.ScaleType = Enum.ScaleType.Slice
imageLabel.SliceCenter = Rect.new(30, 30, 34, 34)
resizeInACircle()
end