Fixed animations where the frame stays the same for periods of time.

This commit is contained in:
Scott Erickson 2014-09-25 13:26:05 -07:00
parent d77b87ed22
commit 4b87607599

View file

@ -196,27 +196,27 @@ module.exports = class SegmentedSprite extends createjs.SpriteContainer
else else
newFrame = newFrame % @animLength newFrame = newFrame % @animLength
return if @currentFrame is newFrame translatedFrame = newFrame
if @frames if @frames
prevFrame = Math.floor(newFrame) prevFrame = Math.floor(newFrame)
nextFrame = Math.ceil(newFrame) nextFrame = Math.ceil(newFrame)
if prevFrame is nextFrame if prevFrame is nextFrame
@baseMovieClip.gotoAndStop(@frames[newFrame]) translatedFrame = @frames[newFrame]
else if nextFrame is @frames.length else if nextFrame is @frames.length
@baseMovieClip.gotoAndStop(@frames[prevFrame]) translatedFrame = @frames[prevFrame]
else else
# interpolate between frames # interpolate between frames
pct = newFrame % 1 pct = newFrame % 1
newFrameIndex = @frames[prevFrame] + (pct * (@frames[nextFrame] - @frames[prevFrame])) newFrameIndex = @frames[prevFrame] + (pct * (@frames[nextFrame] - @frames[prevFrame]))
@baseMovieClip.gotoAndStop(newFrameIndex) translatedFrame = newFrameIndex
else
@baseMovieClip.gotoAndStop(newFrame)
@currentFrame = newFrame @currentFrame = newFrame
@children = [] return if translatedFrame is @baseMovieClip.currentFrame
@baseMovieClip.gotoAndStop(translatedFrame)
movieClip.gotoAndStop(newFrame) for movieClip in @childMovieClips movieClip.gotoAndStop(newFrame) for movieClip in @childMovieClips
@children = []
@takeChildrenFromMovieClip() @takeChildrenFromMovieClip()
takeChildrenFromMovieClip: -> takeChildrenFromMovieClip: ->