Fix camera and spectate bugs with new loading intro behavior

This commit is contained in:
Nick Winter 2015-11-11 06:42:12 -08:00
parent 18eef3b0ec
commit 42b53dff20
4 changed files with 16 additions and 4 deletions

View file

@ -132,6 +132,16 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
setWorldLoading: (@worldLoading) ->
@run() unless @worldLoading
initializeCamera: ->
# Fire off the first bounds-setting script now, before we're actually running any other ones.
for script in @scripts
for note in script.noteChain or []
if note.surface?.focus?
surfaceModule = _.find note.modules or [], (module) -> module.surfaceCameraNote
cameraNote = surfaceModule.surfaceCameraNote true
@publishNote cameraNote
return
destroy: ->
@onEndAll()
clearInterval @tickInterval

View file

@ -93,7 +93,7 @@ module.exports = class SpectateLevelView extends RootView
afterRender: ->
window.onPlayLevelViewLoaded? @ # still a hack
@insertSubView @loadingView = new LoadingView {}
@insertSubView @loadingView = new LoadingView autoUnveil: true, level: @levelLoader?.level ? @level
@$el.find('#level-done-button').hide()
super()
$('body').addClass('is-playing')
@ -151,7 +151,7 @@ module.exports = class SpectateLevelView extends RootView
onLevelStarted: (e) ->
go = =>
@loadingView?.startUnveiling()
@loadingView?.unveil()
@loadingView?.unveil true
_.delay go, 1000
onLoadingViewUnveiled: (e) ->

View file

@ -45,14 +45,14 @@ module.exports = class LevelLoadingView extends CocoView
onLevelLoaded: (e) ->
@level = e.level
@prepareGoals()
@prepareGoals e
@prepareTip()
@prepareIntro()
onSessionLoaded: (e) ->
@session = e.session if e.session.get('creator') is me.id
prepareGoals: ->
prepareGoals: (e) ->
goalContainer = @$el.find('.level-loading-goals')
goalList = goalContainer.find('ul')
goalCount = 0

View file

@ -344,6 +344,8 @@ module.exports = class PlayLevelView extends RootView
if (@isEditorPreview or @observing) and not @getQueryVariable('intro')
@loadingView.startUnveiling()
@loadingView.unveil true
else
@scriptManager.initializeCamera()
onLoadingViewUnveiling: (e) ->
@selectHero()