SoundGroup

显示已弃用

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

一个 SoundGroup 用于管理多个 Sounds 上的音量和效果。音效组中的每个音效的音量都会由该群组的 属性调整,该属性作为倍数,意味着一个音量为 的音效与一个音量为 的音效将有一个有效音量为 。

如果 SoundGroup 有任何 SoundEffects 作为子,那些效果将应用于群组中的所有 Sounds

请注意,必须将 Sound 添加到 SoundGroup 以设置其 SoundGroup 属性,而不是简单地将 Sound 转移到 SoundGroup 。一个 Sound 只能属于一个 SoundGroup 一次,虽然你可以像这里描述的一样嵌套组 .

请参阅声音组了解有关使用SoundGroup的更多细节。

属性

Volume

读取并联

音量倍率应用于 Sounds 属于 SoundGroup 的值可以从 010 范围。

代码示例

This sample demonstrates how a SoundGroup can be used to change the volume of its associated Sounds and apply SoundEffects.

In this example a Sound is instanced in the Workspace and assigned to a new SoundGroup. The Sound is played and during playback the volume is changed via the SoundGroup and a SoundEffect is added.

SoundGroups

local SoundService = game:GetService("SoundService")
-- create a sound group
local soundGroup = Instance.new("SoundGroup")
soundGroup.Parent = SoundService
-- create a sound
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9120386436"
sound.Looped = true
sound.PlaybackSpeed = 2
sound.SoundGroup = soundGroup
sound.Parent = workspace
-- play the sound
sound:Play()
task.wait(10)
-- change the volume
soundGroup.Volume = 0.1
task.wait(3)
-- return the volume
soundGroup.Volume = 0.5
task.wait(4)
-- add a sound effect
local reverb = Instance.new("ReverbSoundEffect")
reverb.Parent = soundGroup

方法

活动