Merge branch 'master' of https://github.com/codecombat/codecombat
This commit is contained in:
commit
7ad6faa0c0
3 changed files with 11 additions and 17 deletions
app/lib
|
@ -70,17 +70,17 @@ class AudioPlayer extends CocoClass
|
||||||
filename = "/file/interface/#{name}#{@ext}"
|
filename = "/file/interface/#{name}#{@ext}"
|
||||||
@preloadSound filename, name
|
@preloadSound filename, name
|
||||||
|
|
||||||
playInterfaceSound: (name) ->
|
playInterfaceSound: (name, volume=1) ->
|
||||||
filename = "/file/interface/#{name}#{@ext}"
|
filename = "/file/interface/#{name}#{@ext}"
|
||||||
if filename of cache and createjs.Sound.loadComplete filename
|
if filename of cache and createjs.Sound.loadComplete filename
|
||||||
@playSound name
|
@playSound name, volume
|
||||||
createjs.Sound.play name
|
createjs.Sound.play name
|
||||||
else
|
else
|
||||||
@preloadInterfaceSounds [name] unless filename of cache
|
@preloadInterfaceSounds [name] unless filename of cache
|
||||||
@soundsToPlayWhenLoaded[name] = true
|
@soundsToPlayWhenLoaded[name] = volume
|
||||||
|
|
||||||
playSound: (name) ->
|
playSound: (name, volume=1) ->
|
||||||
createjs.Sound.play name, {volume: me.get('volume')}
|
createjs.Sound.play name, {volume: me.get('volume') * volume}
|
||||||
|
|
||||||
# # TODO: load Interface sounds somehow, somewhere, somewhen
|
# # TODO: load Interface sounds somehow, somewhere, somewhen
|
||||||
|
|
||||||
|
@ -108,8 +108,8 @@ class AudioPlayer extends CocoClass
|
||||||
return if not media
|
return if not media
|
||||||
media.loaded = true
|
media.loaded = true
|
||||||
media.progress = 1.0
|
media.progress = 1.0
|
||||||
if @soundsToPlayWhenLoaded[media.name]
|
if volume = @soundsToPlayWhenLoaded[media.name]
|
||||||
@playSound media.name
|
@playSound media.name, volume
|
||||||
@soundsToPlayWhenLoaded[media.name] = false
|
@soundsToPlayWhenLoaded[media.name] = false
|
||||||
@notifyProgressChanged()
|
@notifyProgressChanged()
|
||||||
|
|
||||||
|
@ -124,9 +124,3 @@ class AudioPlayer extends CocoClass
|
||||||
|
|
||||||
|
|
||||||
module.exports = new AudioPlayer()
|
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
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ module.exports = class God
|
||||||
@createWorker()
|
@createWorker()
|
||||||
|
|
||||||
createWorker: ->
|
createWorker: ->
|
||||||
console.log "yo create worker"
|
|
||||||
new Worker '/javascripts/workers/worker_world.js'
|
new Worker '/javascripts/workers/worker_world.js'
|
||||||
|
|
||||||
getAngel: ->
|
getAngel: ->
|
||||||
|
@ -188,7 +187,6 @@ class Angel
|
||||||
|
|
||||||
spawnWorker: ->
|
spawnWorker: ->
|
||||||
@worker = @god.getWorker()
|
@worker = @god.getWorker()
|
||||||
console.log "yo got worker", @worker
|
|
||||||
@listen()
|
@listen()
|
||||||
|
|
||||||
enslave: ->
|
enslave: ->
|
||||||
|
|
|
@ -149,7 +149,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
hide: ->
|
hide: ->
|
||||||
@hiding = true
|
@hiding = true
|
||||||
@updateAlpha()
|
@updateAlpha()
|
||||||
|
|
||||||
show: ->
|
show: ->
|
||||||
@hiding = false
|
@hiding = false
|
||||||
@updateAlpha()
|
@updateAlpha()
|
||||||
|
@ -432,6 +432,8 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
playSounds: (withDelay=true, volume=1.0) ->
|
playSounds: (withDelay=true, volume=1.0) ->
|
||||||
for event in @thang.currentEvents ? []
|
for event in @thang.currentEvents ? []
|
||||||
@playSound event, withDelay, volume
|
@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'
|
if @thang.actionActivated and (action = @thang.getActionName()) isnt 'say'
|
||||||
@playSound action, withDelay, volume
|
@playSound action, withDelay, volume
|
||||||
if @thang.sayMessage and withDelay # don't play sayMessages while scrubbing, annoying
|
if @thang.sayMessage and withDelay # don't play sayMessages while scrubbing, annoying
|
||||||
|
|
Reference in a new issue