mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-13 21:44:40 -04:00
Fixed the music starting when you restart the level, even if music is off.
This commit is contained in:
parent
e732e7227c
commit
70525ec57a
1 changed files with 25 additions and 13 deletions
|
@ -21,21 +21,33 @@ module.exports = class MusicPlayer extends CocoClass
|
|||
|
||||
onPlayMusic: (e) ->
|
||||
src = e.file
|
||||
if src
|
||||
src = "/file#{src}#{AudioPlayer.ext}"
|
||||
return @currentMusic.play('none', 0, 0, -1, 0.3) if src is @currentMusic?.src
|
||||
media = AudioPlayer.getStatus(src)
|
||||
if not media?.loaded
|
||||
AudioPlayer.preloadSound(src)
|
||||
@standingBy = e
|
||||
return
|
||||
src = "/file#{e.file}#{AudioPlayer.ext}"
|
||||
if (not e.file) or src is @currentMusic?.src
|
||||
if e.play then @restartCurrentMusic() else @fadeOutCurrentMusic()
|
||||
return
|
||||
|
||||
media = AudioPlayer.getStatus(src)
|
||||
if not media?.loaded
|
||||
AudioPlayer.preloadSound(src)
|
||||
@standingBy = e
|
||||
return
|
||||
|
||||
@standingBy = null
|
||||
if @currentMusic
|
||||
f = -> @stop()
|
||||
createjs.Tween.get(@currentMusic).to({volume:0.0}, CROSSFADE_LENGTH).call(f)
|
||||
|
||||
@currentMusic = createjs.Sound.play(src, 'none', 0, 0, -1, 0.3) if src and e.play
|
||||
@fadeOutCurrentMusic()
|
||||
@startNewMusic(src) if e.play
|
||||
|
||||
restartCurrentMusic: ->
|
||||
return unless @currentMusic
|
||||
@currentMusic.play('none', 0, 0, -1, 0.3)
|
||||
@updateMusicVolume()
|
||||
|
||||
fadeOutCurrentMusic: ->
|
||||
return unless @currentMusic
|
||||
f = -> @stop()
|
||||
createjs.Tween.get(@currentMusic).to({volume:0.0}, CROSSFADE_LENGTH).call(f)
|
||||
|
||||
startNewMusic: (src) ->
|
||||
@currentMusic = createjs.Sound.play(src, 'none', 0, 0, -1, 0.3) if src
|
||||
return unless @currentMusic
|
||||
@currentMusic.volume = 0.0
|
||||
if me.get('music')
|
||||
|
|
Loading…
Add table
Reference in a new issue