mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-27 06:23:41 -04:00
Added WorldMapView ambient sounds.
This commit is contained in:
parent
68bb1dc135
commit
2ed6b737c2
1 changed files with 17 additions and 0 deletions
|
@ -33,9 +33,13 @@ module.exports = class WorldMapView extends RootView
|
|||
@listenToOnce @sessions, 'sync', @onSessionsLoaded
|
||||
@getLevelPlayCounts()
|
||||
$(window).on 'resize', @onWindowResize
|
||||
@playAmbientSound()
|
||||
|
||||
destroy: ->
|
||||
$(window).off 'resize', @onWindowResize
|
||||
if ambientSound = @ambientSound
|
||||
# Doesn't seem to work; stops immediately.
|
||||
createjs.Tween.get(ambientSound).to({volume: 0.0}, 1500).call -> ambientSound.stop()
|
||||
super()
|
||||
|
||||
getLevelPlayCounts: ->
|
||||
|
@ -156,6 +160,19 @@ module.exports = class WorldMapView extends RootView
|
|||
resultingMarginY = (pageHeight - resultingHeight) / 2
|
||||
@$el.find('.map').css(width: resultingWidth, height: resultingHeight, 'margin-left': resultingMarginX, 'margin-top': resultingMarginY)
|
||||
|
||||
playAmbientSound: ->
|
||||
return if @ambientSound
|
||||
terrain = 'Grass'
|
||||
return unless file = {Dungeon: 'ambient-map-dungeon', Grass: 'ambient-map-grass'}[terrain]
|
||||
src = "/file/interface/#{file}#{AudioPlayer.ext}"
|
||||
unless AudioPlayer.getStatus(src)?.loaded
|
||||
AudioPlayer.preloadSound src
|
||||
Backbone.Mediator.subscribeOnce 'audio-player:loaded', @playAmbientSound, @
|
||||
return
|
||||
@ambientSound = createjs.Sound.play src, loop: -1, volume: 0.1
|
||||
createjs.Tween.get(@ambientSound).to({volume: 1.0}, 1000)
|
||||
|
||||
|
||||
tutorials = [
|
||||
{
|
||||
name: 'Rescue Mission'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue