Sparkles

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

闪光是几个发射粒子的类别之一。像其他类似类型的粒子发射器一样,火花对象在被父辈到一个 (例如一个 ) 或在这样的 内发射粒子。与 ParticleEmitter 类相比,闪光缺乏许多不同的自定义属性和特殊方法,例如 ParticleEmitter.LifetimeParticleEmitter:Emit() 。在紧急情况下创建快速特效有用;对于更详细的工作,建议使用 ParticleEmitter 来进行。

Sparkles.Enabled关闭时,由此对象发射的粒子将继续渲染,直到其生命周期到期。当闪光对象的 Instance.Parent 设置为 nil (和/或 Instance:Destroy() 编辑)时,所有粒子将立即消失。如果不想要这种效果,请尝试隐藏父对象在遥远位置,然后使用 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.

Give Sparkles

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 相似,除了它只有一个颜色而不是 ColorSequence 。闪光具有自然的颜色顺序,当此属性设置为白色时最为明显;闪光非常淡定地在柔和的绿色和红色之间动画;

需要注意的是,闪光具有部分ParticleEmitter.LightEmission效果,因此深色往往更透明,白色看起来更亮。

代码示例

The code sample below gives any new players sparkles that are colored the same as their torso color.

Give Sparkles

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.

Give Sparkles

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 相似,除了它只有一个颜色而不是 ColorSequence 。闪光具有自然的颜色顺序,当此属性设置为白色时最为明显;闪光非常淡定地在柔和的绿色和红色之间动画;

需要注意的是,闪光具有部分ParticleEmitter.LightEmission效果,因此深色往往更透明,白色看起来更亮。

代码示例

The code sample below gives any new players sparkles that are colored the same as their torso color.

Give Sparkles

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)

TimeScale

读取并联

方法

活动