Figured out how to get the world to properly get shown if the world is created before the level loader is completely finished.

This commit is contained in:
Scott Erickson 2014-05-14 10:35:16 -07:00
parent cab1adf8fc
commit 0be813e424
2 changed files with 5 additions and 7 deletions

View file

@ -84,6 +84,8 @@ module.exports = Surface = class Surface extends CocoClass
@initAudio()
@onResize = _.debounce @onResize, 500
$(window).on 'resize', @onResize
if @world.ended
_.defer => @setWorld @world
destroy: ->
@dead = true

View file

@ -60,7 +60,6 @@ module.exports = class PlayLevelView extends View
'surface:world-set-up': 'onSurfaceSetUpNewWorld'
'level:session-will-save': 'onSessionWillSave'
'level:set-team': 'setTeam'
'god:new-world-created': 'loadSoundsForWorld'
'level:started': 'onLevelStarted'
'level:loading-view-unveiled': 'onLoadingViewUnveiled'
@ -309,9 +308,6 @@ module.exports = class PlayLevelView extends View
$('#level-done-button', @$el).hide()
application.tracker?.trackEvent 'Confirmed Restart', level: @world.name, label: @world.name
onNewWorld: (e) ->
@world = e.world
onInfiniteLoop: (e) ->
return unless e.firstWorld
@openModalView new InfiniteLoopModal()
@ -484,11 +480,11 @@ module.exports = class PlayLevelView extends View
# Dynamic sound loading
loadSoundsForWorld: (e) ->
onNewWorld: (e) ->
return if @headless
world = e.world
@world = e.world
thangTypes = @supermodel.getModels(ThangType)
for [spriteName, message] in world.thangDialogueSounds()
for [spriteName, message] in @world.thangDialogueSounds()
continue unless thangType = _.find thangTypes, (m) -> m.get('name') is spriteName
continue unless sound = AudioPlayer.soundForDialogue message, thangType.get('soundTriggers')
AudioPlayer.preloadSoundReference sound