Sets the current volume of the Source.
Source:setVolume( volume )
number volume
Nothing.
Make a sound quieter or completely silent.
function love.load() sound = love.audio.newSource("sound.wav") -- Note that this code, as-is, will set the volume to 0.0, as per the last line, and that's how sound:play() will play it back. sound:setVolume(0.5) -- 50% volume sound:setVolume(0) -- No sound sound:setVolume(1) -- Reset to maximum volume. end
Set different volumes depending on the sound type.
function love.load() effect = love.audio.newSource("soundeffect.wav") music = love.audio.newSource("music.mp3") masterVolume = 0.5 -- Maximum volume for all sounds effectVolume = 0.75 musicVolume = 1 effect:setVolume(masterVolume * effectVolume) music:setVolume(masterVolume * musicVolume) end
© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/Source:setVolume