Improve audio effects handling and update spell sound filter type
This commit is contained in:
parent
fc5a39b1d2
commit
a4e2a2f257
@ -1,6 +1,8 @@
|
|||||||
local ease = require "lib.utils.easing"
|
local ease = require "lib.utils.easing"
|
||||||
local AnimationNode = require "lib.animation_node"
|
local AnimationNode = require "lib.animation_node"
|
||||||
|
|
||||||
|
local EFFECTS_SUPPORTED = love.audio.isEffectsSupported()
|
||||||
|
|
||||||
--- @alias SourceFilter { type: "bandpass"|"highpass"|"lowpass", volume: number, highgain: number, lowgain: number }
|
--- @alias SourceFilter { type: "bandpass"|"highpass"|"lowpass", volume: number, highgain: number, lowgain: number }
|
||||||
|
|
||||||
--- @class Audio
|
--- @class Audio
|
||||||
@ -62,19 +64,20 @@ end
|
|||||||
--- @param settings SourceFilter?
|
--- @param settings SourceFilter?
|
||||||
--- @param effectName string?
|
--- @param effectName string?
|
||||||
function audio:play(source, settings, effectName)
|
function audio:play(source, settings, effectName)
|
||||||
if settings then
|
|
||||||
source:setFilter(settings)
|
|
||||||
end
|
|
||||||
if effectName then
|
|
||||||
source:setEffect(effectName, true)
|
|
||||||
end
|
|
||||||
if source:getType() == "stream" then
|
if source:getType() == "stream" then
|
||||||
source:setLooping(self.looped)
|
source:setLooping(self.looped)
|
||||||
source:setVolume(self.musicVolume)
|
source:setVolume(self.musicVolume)
|
||||||
return source:play()
|
source:play()
|
||||||
|
else
|
||||||
|
source:setVolume(self.soundVolume)
|
||||||
|
source:play()
|
||||||
|
end
|
||||||
|
if settings and EFFECTS_SUPPORTED then
|
||||||
|
source.setFilter(source, settings)
|
||||||
|
end
|
||||||
|
if effectName and EFFECTS_SUPPORTED then
|
||||||
|
source:setEffect(effectName, true)
|
||||||
end
|
end
|
||||||
source:setVolume(self.soundVolume)
|
|
||||||
return source:play()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function audio:setMusicVolume(volume)
|
function audio:setMusicVolume(volume)
|
||||||
|
|||||||
@ -172,9 +172,8 @@ function attack:cast(caster, target)
|
|||||||
targetSprite:animate("hurt", node)
|
targetSprite:animate("hurt", node)
|
||||||
--- @type SourceFilter
|
--- @type SourceFilter
|
||||||
local settings = {
|
local settings = {
|
||||||
type = "bandpass",
|
type = "highpass",
|
||||||
volume = 1,
|
volume = 1,
|
||||||
highgain = 0.1,
|
|
||||||
lowgain = 0.1
|
lowgain = 0.1
|
||||||
}
|
}
|
||||||
Tree.audio:play(audioPath.sounds.hurt, settings)
|
Tree.audio:play(audioPath.sounds.hurt, settings)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user