Make it much less likely to get to frame 0, since that frame is often pretty weird.

This commit is contained in:
Nick Winter 2014-11-19 15:46:50 -08:00
parent 41db27c709
commit a1038af32b
2 changed files with 5 additions and 2 deletions

View file

@ -258,7 +258,9 @@ module.exports = Surface = class Surface extends CocoClass
createjs.Tween.removeTweens(@)
@currentFrame = @scrubbingTo
@scrubbingTo = Math.min(Math.round(progress * (@world.frames.length - 1)), @world.frames.length - 1)
@scrubbingTo = Math.round(progress * (@world.frames.length - 1))
@scrubbingTo = Math.max @scrubbingTo, 1
@scrubbingTo = Math.min @scrubbingTo, @world.frames.length - 1
@scrubbingPlaybackSpeed = Math.sqrt(Math.abs(@scrubbingTo - @currentFrame) * @world.dt / (scrubDuration or 0.5))
if scrubDuration
t = createjs.Tween
@ -402,7 +404,7 @@ module.exports = Surface = class Surface extends CocoClass
@playing = (e ? {}).playing ? true
@setPlayingCalled = true
if @playing and @currentFrame >= (@world.totalFrames - 5)
@currentFrame = 0
@currentFrame = 1 # Go back to the beginning (but not frame 0, that frame is weird)
if @fastForwardingToFrame and not @playing
@fastForwardingToFrame = null

View file

@ -210,6 +210,7 @@ module.exports = class LevelPlaybackView extends CocoView
onProgressHover: (e, offsetX) ->
timeRatio = @$progressScrubber.width() / @totalTime
offsetX ?= e.clientX - $(e.target).closest('#timeProgress').offset().left
offsetX = Math.max 0, offsetX
@newTime = offsetX / timeRatio
@updatePopupContent()
@timePopup?.onHover e