From 1e94fdffac0a3c69c12cf9db1df20ae6a8f05ae6 Mon Sep 17 00:00:00 2001 From: Roger Zanoni Date: Sun, 21 Oct 2018 01:01:30 +0200 Subject: [PATCH] Allow concurrent sfx --- gunner.lua | 2 +- melee.lua | 2 +- soundmanager.lua | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gunner.lua b/gunner.lua index c387632..243909c 100644 --- a/gunner.lua +++ b/gunner.lua @@ -145,7 +145,7 @@ function Gunner:attack() self:shoot() self.target:receiveDamage(self.damage) self:changeState(STATE_IDLE) - soundManager:play("laser") + soundManager:playSfx("laser") else self.attacking_timer = self.attacking_timer + 1 end diff --git a/melee.lua b/melee.lua index 2b5c491..d7b86a8 100644 --- a/melee.lua +++ b/melee.lua @@ -123,7 +123,7 @@ function Melee:attack() self.attacking_timer = 0 self.target:receiveDamage(self.damage) self:changeState(STATE_IDLE) - soundManager:play("melee") + soundManager:playSfx("melee") else self.attacking_timer = self.attacking_timer + 1 end diff --git a/soundmanager.lua b/soundmanager.lua index c484484..887c7dc 100644 --- a/soundmanager.lua +++ b/soundmanager.lua @@ -24,6 +24,11 @@ function SoundManager:play(name) source:play() end +function SoundManager:playSfx(name) + local source = self.sounds[name] + source:clone():play() +end + function SoundManager:stop(name) local source = self.sounds[name] source:stop()