codecombat/app/lib/surface/PlaybackOverScreen.coffee

38 lines
1.1 KiB
CoffeeScript
Raw Normal View History

2014-02-25 20:14:39 -05:00
CocoClass = require 'lib/CocoClass'
module.exports = class PlaybackOverScreen extends CocoClass
2014-02-25 20:14:39 -05:00
constructor: (options) ->
super()
options ?= {}
@camera = options.camera
@layer = options.layer
2014-06-30 22:16:26 -04:00
console.error @toString(), 'needs a camera.' unless @camera
console.error @toString(), 'needs a layer.' unless @layer
2014-02-25 20:14:39 -05:00
@build()
2014-06-30 22:16:26 -04:00
toString: -> '<PlaybackOverScreen>'
2014-02-25 20:14:39 -05:00
build: ->
@dimLayer = new createjs.Container()
@dimLayer.mouseEnabled = @dimLayer.mouseChildren = false
@dimLayer.addChild @dimScreen = new createjs.Shape()
2014-06-30 22:16:26 -04:00
@dimScreen.graphics.beginFill('rgba(0,0,0,0.4)').rect 0, 0, @camera.canvasWidth, @camera.canvasHeight
2014-02-25 20:14:39 -05:00
@dimLayer.cache 0, 0, @camera.canvasWidth, @camera.canvasHeight
@dimLayer.alpha = 0
@layer.addChild @dimLayer
show: ->
return if @showing
@showing = true
2014-02-25 20:14:39 -05:00
@dimLayer.alpha = 0
createjs.Tween.removeTweens @dimLayer
2014-06-30 22:16:26 -04:00
createjs.Tween.get(@dimLayer).to({alpha: 1}, 500)
2014-02-25 20:14:39 -05:00
hide: ->
return unless @showing
@showing = false
2014-02-25 20:14:39 -05:00
createjs.Tween.removeTweens @dimLayer
2014-06-30 22:16:26 -04:00
createjs.Tween.get(@dimLayer).to({alpha: 0}, 500)