mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Fixed #453.
This commit is contained in:
parent
50ad453345
commit
a5c18a4140
2 changed files with 9 additions and 6 deletions
|
@ -89,8 +89,10 @@ class AudioPlayer extends CocoClass
|
|||
|
||||
playSound: (name, volume=1, delay=0, pos=null) ->
|
||||
audioOptions = {volume: (me.get('volume') ? 1) * volume, delay: delay}
|
||||
unless @camera is null or pos is null
|
||||
audioOptions = @applyPanning audioOptions, pos
|
||||
filename = if _.string.startsWith(name, '/file/') then name else '/file/' + name
|
||||
unless (filename of cache) and createjs.Sound.loadComplete filename
|
||||
@soundsToPlayWhenLoaded[name] = audioOptions.volume
|
||||
audioOptions = @applyPanning audioOptions, pos if @camera and pos
|
||||
instance = createjs.Sound.play name, audioOptions
|
||||
instance
|
||||
|
||||
|
|
|
@ -678,14 +678,14 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
label = @addLabel 'dialogue', Label.STYLE_DIALOGUE
|
||||
label.setText e.blurb or '...'
|
||||
sound = e.sound ? AudioPlayer.soundForDialogue e.message, @thangType.get 'soundTriggers'
|
||||
@instance?.stop()
|
||||
if @instance = @playSound sound, false
|
||||
@instance.addEventListener 'complete', -> Backbone.Mediator.publish 'dialogue-sound-completed'
|
||||
@dialogueSoundInstance?.stop()
|
||||
if @dialogueSoundInstance = @playSound sound, false
|
||||
@dialogueSoundInstance.addEventListener 'complete', -> Backbone.Mediator.publish 'dialogue-sound-completed'
|
||||
@notifySpeechUpdated e
|
||||
|
||||
onClearDialogue: (e) ->
|
||||
@labels.dialogue?.setText null
|
||||
@instance?.stop()
|
||||
@dialogueSoundInstance?.stop()
|
||||
@notifySpeechUpdated {}
|
||||
|
||||
setNameLabel: (name) ->
|
||||
|
@ -733,6 +733,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
return null unless sound
|
||||
delay = if withDelay and sound.delay then 1000 * sound.delay / createjs.Ticker.getFPS() else 0
|
||||
name = AudioPlayer.nameForSoundReference sound
|
||||
AudioPlayer.preloadSoundReference sound
|
||||
instance = AudioPlayer.playSound name, volume, delay, @getWorldPosition()
|
||||
#console.log @thang?.id, 'played sound', name, 'with delay', delay, 'volume', volume, 'and got sound instance', instance
|
||||
instance
|
||||
|
|
Loading…
Reference in a new issue