TrailMaster plays/pauses animations along with the rest of the Surface.

This commit is contained in:
Scott Erickson 2014-11-18 16:03:47 -08:00
parent c23fb1d2b5
commit c40a7c1bb8
2 changed files with 12 additions and 1 deletions

View file

@ -312,10 +312,12 @@ module.exports = Surface = class Surface extends CocoClass
if paused
@surfacePauseTimeout = _.delay performToggle, 2000
@lankBoss.stop()
@trailmaster?.stop()
@playbackOverScreen.show()
else
performToggle()
@lankBoss.play()
@trailmaster?.play()
@playbackOverScreen.hide()

View file

@ -14,6 +14,7 @@ module.exports = class TrailMaster extends CocoClass
constructor: (@camera, @layerAdapter) ->
super()
@tweenedSprites = []
@tweens = []
@listenTo @layerAdapter, 'new-spritesheet', -> @generatePaths(@world, @thang)
generatePaths: (@world, @thang) ->
@ -32,6 +33,7 @@ module.exports = class TrailMaster extends CocoClass
cleanUp: ->
createjs.Tween.removeTweens(sprite) for sprite in @tweenedSprites
@tweenedSprites = []
@tweens = []
createGraphics: ->
color = @colorForThang(@thang.team, PAST_PATH_ALPHA)
@ -96,12 +98,19 @@ module.exports = class TrailMaster extends CocoClass
sprite.y = y
container.addChild(sprite)
if lastSprite and options.animate
createjs.Tween.get(lastSprite, {loop: true}).to({x:x, y:y}, 1000)
tween = createjs.Tween.get(lastSprite, {loop: true}).to({x:x, y:y}, 1000)
@tweenedSprites.push lastSprite
@tweens.push tween
lastSprite = sprite
@logged = true
container
play: ->
tween.setPaused(false) for tween in @tweens
stop: ->
tween.setPaused(true) for tween in @tweens
destroy: ->
@cleanUp()