Skip to content

Commit

Permalink
Allow concurrent sfx
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerzanoni committed Oct 20, 2018
1 parent e08d120 commit 1e94fdf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gunner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion melee.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions soundmanager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 1e94fdf

Please sign in to comment.