Skip to content

Commit

Permalink
Merge pull request #50 from largato/sfx
Browse files Browse the repository at this point in the history
Allow concurrent sfx
  • Loading branch information
luizcavalcanti authored Oct 20, 2018
2 parents df764b3 + 1e94fdf commit f81a9b7
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 @@ -125,7 +125,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 @@ -121,7 +121,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 f81a9b7

Please sign in to comment.