mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Fixed animations where the frame stays the same for periods of time.
This commit is contained in:
parent
d77b87ed22
commit
4b87607599
1 changed files with 7 additions and 7 deletions
|
@ -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: ->
|
||||||
|
|
Loading…
Reference in a new issue