Fixed a bug where sometimes scripts setting playback would be overridden by the surface resetting playback after casting is done.

This commit is contained in:
Scott Erickson 2014-05-20 12:21:43 -07:00
parent 3f884e71e5
commit 2b56dffcb0

View file

@ -281,6 +281,7 @@ module.exports = Surface = class Surface extends CocoClass
onSetPlaying: (e) ->
@playing = (e ? {}).playing ? true
@setPlayingCalled = true
if @playing and @currentFrame >= (@world.totalFrames - 5)
@currentFrame = 0
if @fastForwarding and not @playing
@ -352,6 +353,7 @@ module.exports = Surface = class Surface extends CocoClass
@casting = true
@wasPlayingWhenCastingBegan = @playing
Backbone.Mediator.publish 'level-set-playing', { playing: false }
@setPlayingCalled = false # don't overwrite playing settings if they changed by, say, scripts
if @coordinateDisplay?
@surfaceTextLayer.removeChild @coordinateDisplay
@ -370,7 +372,7 @@ module.exports = Surface = class Surface extends CocoClass
# This has a tendency to break scripts that are waiting for playback to change when the level is loaded
# so only run it after the first world is created.
Backbone.Mediator.publish 'level-set-playing', { playing: @wasPlayingWhenCastingBegan } unless event.firstWorld
Backbone.Mediator.publish 'level-set-playing', { playing: @wasPlayingWhenCastingBegan } unless event.firstWorld or @setPlayingCalled
fastForwardTo = null
if @playing