mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Misc changes, wishing I could get sounds to work at lower volumes.
This commit is contained in:
parent
0b1f4ebada
commit
f53f6bf0a3
3 changed files with 15 additions and 7 deletions
|
@ -81,7 +81,7 @@ class AudioPlayer extends CocoClass
|
||||||
|
|
||||||
playInterfaceSound: (name, volume=1) ->
|
playInterfaceSound: (name, volume=1) ->
|
||||||
filename = "/file/interface/#{name}#{@ext}"
|
filename = "/file/interface/#{name}#{@ext}"
|
||||||
if filename of cache and createjs.Sound.loadComplete filename
|
if @hasLoadedSound filename
|
||||||
@playSound name, volume
|
@playSound name, volume
|
||||||
else
|
else
|
||||||
@preloadInterfaceSounds [name] unless filename of cache
|
@preloadInterfaceSounds [name] unless filename of cache
|
||||||
|
@ -89,15 +89,23 @@ class AudioPlayer extends CocoClass
|
||||||
|
|
||||||
playSound: (name, volume=1, delay=0, pos=null) ->
|
playSound: (name, volume=1, delay=0, pos=null) ->
|
||||||
return console.error 'Trying to play empty sound?' unless name
|
return console.error 'Trying to play empty sound?' unless name
|
||||||
audioOptions = {volume: (me.get('volume') ? 1) * volume, delay: delay}
|
audioOptions = {volume: volume, delay: delay}
|
||||||
filename = if _.string.startsWith(name, '/file/') then name else '/file/' + name
|
filename = if _.string.startsWith(name, '/file/') then name else '/file/' + name
|
||||||
unless (filename of cache) and createjs.Sound.loadComplete filename
|
unless @hasLoadedSound filename
|
||||||
@soundsToPlayWhenLoaded[name] = audioOptions.volume
|
@soundsToPlayWhenLoaded[name] = audioOptions.volume
|
||||||
audioOptions = @applyPanning audioOptions, pos if @camera and pos
|
audioOptions = @applyPanning audioOptions, pos if @camera and pos
|
||||||
instance = createjs.Sound.play name, audioOptions
|
instance = createjs.Sound.play name, audioOptions
|
||||||
|
# For some reason, individual sound volume control doesn't work any more.
|
||||||
|
# I tried updating to SoundJS NEXT on 2014-09-10, but couldn't get any sounds to play with that one.
|
||||||
|
#console.log 'got instance with volume', instance.volume, instance._volume, instance.gainNode?.gain.value
|
||||||
instance
|
instance
|
||||||
|
|
||||||
# # TODO: load Interface sounds somehow, somewhere, somewhen
|
hasLoadedSound: (filename, name) ->
|
||||||
|
return false unless filename of cache
|
||||||
|
return false unless createjs.Sound.loadComplete filename
|
||||||
|
true
|
||||||
|
|
||||||
|
# TODO: load Interface sounds somehow, somewhere, somewhen
|
||||||
|
|
||||||
preloadSoundReference: (sound) ->
|
preloadSoundReference: (sound) ->
|
||||||
name = @nameForSoundReference sound
|
name = @nameForSoundReference sound
|
||||||
|
|
|
@ -41,7 +41,7 @@ module.exports =
|
||||||
|
|
||||||
'tome:palette-updated': c.object {title: 'Palette Updated', description: 'Published when the spell palette has just been updated.'},
|
'tome:palette-updated': c.object {title: 'Palette Updated', description: 'Published when the spell palette has just been updated.'},
|
||||||
thangID: {type: 'string'}
|
thangID: {type: 'string'}
|
||||||
entryGroups: {type: 'object', additionalProperties: {type: 'string'}}
|
entryGroups: {type: 'string'}
|
||||||
|
|
||||||
'tome:palette-hovered': c.object {title: 'Palette Hovered', description: 'Published when you hover over a Thang in the spell palette', required: ['thang', 'prop', 'entry']},
|
'tome:palette-hovered': c.object {title: 'Palette Hovered', description: 'Published when you hover over a Thang in the spell palette', required: ['thang', 'prop', 'entry']},
|
||||||
thang: {type: 'object'}
|
thang: {type: 'object'}
|
||||||
|
|
|
@ -339,7 +339,7 @@ module.exports = class LevelPlaybackView extends CocoView
|
||||||
@slideCount = 0
|
@slideCount = 0
|
||||||
@wasPlaying = @playing
|
@wasPlaying = @playing
|
||||||
Backbone.Mediator.publish 'level:set-playing', {playing: false}
|
Backbone.Mediator.publish 'level:set-playing', {playing: false}
|
||||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'playback-scrub-start', volume: 1
|
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'playback-scrub-start', volume: 0.5
|
||||||
|
|
||||||
stop: (event, ui) =>
|
stop: (event, ui) =>
|
||||||
return if @shouldIgnore()
|
return if @shouldIgnore()
|
||||||
|
@ -351,7 +351,7 @@ module.exports = class LevelPlaybackView extends CocoView
|
||||||
Backbone.Mediator.publish 'level:set-playing', {playing: false}
|
Backbone.Mediator.publish 'level:set-playing', {playing: false}
|
||||||
@$el.find('.scrubber-handle').effect('bounce', {times: 2})
|
@$el.find('.scrubber-handle').effect('bounce', {times: 2})
|
||||||
else
|
else
|
||||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'playback-scrub-end', volume: 1
|
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'playback-scrub-end', volume: 0.5
|
||||||
)
|
)
|
||||||
|
|
||||||
getScrubRatio: ->
|
getScrubRatio: ->
|
||||||
|
|
Loading…
Reference in a new issue