Sparkles
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
スパークルは複数の粒子放射クラスの 1つです。同様の他の粒子エミッターと同様に、スパークルオブジェクトは、親に (例: ) またはそのような 内の粒子を放射します。ParticleEmitter クラスと比較して、スパークルは ParticleEmitter.Lifetime または ParticleEmitter:Emit() などの多くの異なるカスタマイズプロパティと特別なメソッドが欠落しています。ピンチで素早い特殊効果を作成するのは便利です;詳細な作業のためには、代わりに ParticleEmitter を使用することを推奨します。
Sparkles.Enabled が切り替えられると、このオブジェクトによって放オフされる粒子は、期限が切れるまでレンダリングを続けます。スパークルオブジェクトの が に設定されると、すべてのパーティクルがすぐに消えます。この効果が望ましくない場合は、親オブジェクトを遠くの位置に隠し、Debris を使用して数秒後にスパークルを削除して、最後の粒子が期限切れするチャンスを与えます。このオブジェクトには ParticleEmitter:Clear() メソッドはありませんが、Instance.Parent を nil に設定し、同じ効果で同じオブジェクトに戻すことができます。
スパークルパーティクルは、親属している BasePart の中心からのみ放出されます。スパークルオブジェクトを Attachment に親にすることで、パーティクルの開始位置のカスタマイズが可能になります。
コードサンプル
The code sample below gives any new players sparkles that are colored the same as their torso color.
local Players = game:GetService("Players")
local function onCharacterSpawned(character)
local hrp = character:WaitForChild("HumanoidRootPart")
-- Add sparkles that are colored to the player's torso color
local sparkles = Instance.new("Sparkles")
sparkles.Parent = hrp
sparkles.SparkleColor = character:WaitForChild("Body Colors").TorsoColor.Color
sparkles.Enabled = true
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterSpawned)
end
Players.PlayerAdded:Connect(onPlayerAdded)
概要
プロパティ
スパークルパーティクルの色を決定します。
キラキラが放出されるかどうかを決定します。
スパークルパーティクルの色を決定します。
プロパティ
Color
カラープロパティは、Sparkles オブジェクト (既存のパーティクルと将来のパーティクルの両方) によって放出されるすべてのパーティクルの色を決定します。それは、ParticleEmitter.Color と同様に動作しますが、1色であり、ColorSequence ではありません。スパークルには自然な色順序が適用され、このプロパティが白に設定されると最も顕著になります;スパークルは非常に弱く、微妙な緑と赤の間でアニメーションします。
キラキラには部分的な ParticleEmitter.LightEmission 効果があるため、暗い色はより透明にレンダリングし、白い色は非常に明るく見えます。
コードサンプル
The code sample below gives any new players sparkles that are colored the same as their torso color.
local Players = game:GetService("Players")
local function onCharacterSpawned(character)
local hrp = character:WaitForChild("HumanoidRootPart")
-- Add sparkles that are colored to the player's torso color
local sparkles = Instance.new("Sparkles")
sparkles.Parent = hrp
sparkles.SparkleColor = character:WaitForChild("Body Colors").TorsoColor.Color
sparkles.Enabled = true
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterSpawned)
end
Players.PlayerAdded:Connect(onPlayerAdded)
Enabled
有効属性は、ParticleEmitter.Enabled と同様に、スパークルパーティクルが発射されるかどうかを決定します。既に放出されているすべての粒子は、期限が切れるまでレンダリングを続けます。このプロパティは、後で必要になるまでプリメイドのスパークル効果を保持するのに便利です。スパークル粒子は、Sparkle オブジェクトの Instance.Parent が nil に設定されると破壊されるため、このプロパティは、既存の粒子がファイアオブジェクト全体を破壊する前に期限切れになる機会を与えることができます。以下の機能を参照してください。
local Debris = game:GetService("Debris")
local part = script.Parent
function stopSparkling(sparkles)
sparkles.Enabled = false -- No more new particles
Debris:AddItem(sparkles, 4) -- Remove the object after a delay (after existing particles have expired)
end
stopSparkling(part.Sparkles)
コードサンプル
The code sample below gives any new players sparkles that are colored the same as their torso color.
local Players = game:GetService("Players")
local function onCharacterSpawned(character)
local hrp = character:WaitForChild("HumanoidRootPart")
-- Add sparkles that are colored to the player's torso color
local sparkles = Instance.new("Sparkles")
sparkles.Parent = hrp
sparkles.SparkleColor = character:WaitForChild("Body Colors").TorsoColor.Color
sparkles.Enabled = true
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterSpawned)
end
Players.PlayerAdded:Connect(onPlayerAdded)
LocalTransparencyModifier
SparkleColor
このプロパティは、Sparkles.Colorと同じ機能を果たします。
スパークルカラープロパティは、Sparkles オブジェクト (既存のパーティクルと将来のパーティクルの両方) によって放出されるすべてのパーティクルの色を決定します。それは、ParticleEmitter.Color と同様に動作しますが、1色であり、ColorSequence ではありません。スパークルには自然な色順序が適用され、このプロパティが白に設定されると最も顕著になります;スパークルは非常に弱く、微妙な緑と赤の間でアニメーションします。
キラキラには部分的な ParticleEmitter.LightEmission 効果があるため、暗い色はより透明にレンダリングし、白い色は非常に明るく見えます。
コードサンプル
The code sample below gives any new players sparkles that are colored the same as their torso color.
local Players = game:GetService("Players")
local function onCharacterSpawned(character)
local hrp = character:WaitForChild("HumanoidRootPart")
-- Add sparkles that are colored to the player's torso color
local sparkles = Instance.new("Sparkles")
sparkles.Parent = hrp
sparkles.SparkleColor = character:WaitForChild("Body Colors").TorsoColor.Color
sparkles.Enabled = true
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterSpawned)
end
Players.PlayerAdded:Connect(onPlayerAdded)