This commit is contained in:
Scott Erickson 2014-02-11 11:31:13 -08:00
commit 7ad6faa0c0
3 changed files with 11 additions and 17 deletions

View file

@ -70,17 +70,17 @@ class AudioPlayer extends CocoClass
filename = "/file/interface/#{name}#{@ext}"
@preloadSound filename, name
playInterfaceSound: (name) ->
playInterfaceSound: (name, volume=1) ->
filename = "/file/interface/#{name}#{@ext}"
if filename of cache and createjs.Sound.loadComplete filename
@playSound name
@playSound name, volume
createjs.Sound.play name
else
@preloadInterfaceSounds [name] unless filename of cache
@soundsToPlayWhenLoaded[name] = true
playSound: (name) ->
createjs.Sound.play name, {volume: me.get('volume')}
@soundsToPlayWhenLoaded[name] = volume
playSound: (name, volume=1) ->
createjs.Sound.play name, {volume: me.get('volume') * volume}
# # TODO: load Interface sounds somehow, somewhere, somewhen
@ -108,8 +108,8 @@ class AudioPlayer extends CocoClass
return if not media
media.loaded = true
media.progress = 1.0
if @soundsToPlayWhenLoaded[media.name]
@playSound media.name
if volume = @soundsToPlayWhenLoaded[media.name]
@playSound media.name, volume
@soundsToPlayWhenLoaded[media.name] = false
@notifyProgressChanged()
@ -124,9 +124,3 @@ class AudioPlayer extends CocoClass
module.exports = new AudioPlayer()
average = (numbers) ->
return 0 if numbers.length is 0
sum = 0
sum += num for num in numbers
return sum / numbers.length

View file

@ -40,7 +40,6 @@ module.exports = class God
@createWorker()
createWorker: ->
console.log "yo create worker"
new Worker '/javascripts/workers/worker_world.js'
getAngel: ->
@ -188,7 +187,6 @@ class Angel
spawnWorker: ->
@worker = @god.getWorker()
console.log "yo got worker", @worker
@listen()
enslave: ->

View file

@ -149,7 +149,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
hide: ->
@hiding = true
@updateAlpha()
show: ->
@hiding = false
@updateAlpha()
@ -432,6 +432,8 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
playSounds: (withDelay=true, volume=1.0) ->
for event in @thang.currentEvents ? []
@playSound event, withDelay, volume
if event is 'pay-bounty-gold' and @thang.bountyGold > 25
AudioPlayer.playInterfaceSound 'coin_1', 0.25
if @thang.actionActivated and (action = @thang.getActionName()) isnt 'say'
@playSound action, withDelay, volume
if @thang.sayMessage and withDelay # don't play sayMessages while scrubbing, annoying