Reenabled text events.

This commit is contained in:
Scott Erickson 2014-09-26 15:57:24 -07:00
parent b89a6c41a7
commit 8234db333e
2 changed files with 26 additions and 27 deletions

View file

@ -228,29 +228,28 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
delete @handledDisplayEvents[event]
showTextEvents: ->
# TODO: Add back text events, once this has been integrated with the Surface
# return unless @thang?.currentEvents
# for event in @thang.currentEvents
# continue unless event.startsWith 'text-'
# continue if @handledDisplayEvents[event]
# @handledDisplayEvents[event] = true
# options = JSON.parse(event[5...])
# label = new createjs.Text options.text, "bold #{options.size or 16}px Arial", options.color or '#FFF'
# shadowColor = {humans: '#F00', ogres: '#00F', neutral: '#0F0', common: '#0F0'}[@thang.team] ? '#000'
# label.shadow = new createjs.Shadow shadowColor, 1, 1, 3
# offset = @getOffset 'aboveHead'
# [label.x, label.y] = [@imageObject.x + offset.x - label.getMeasuredWidth() / 2, @imageObject.y + offset.y]
# @options.floatingLayer.addChild label
# window.labels ?= []
# window.labels.push label
# label.alpha = 0
# createjs.Tween.get(label)
# .to({y: label.y-2, alpha: 1}, 200, createjs.Ease.linear)
# .to({y: label.y-12}, 1000, createjs.Ease.linear)
# .to({y: label.y-22, alpha: 0}, 1000, createjs.Ease.linear)
# .call =>
# return if @destroyed
# @options.floatingLayer.removeChild label
return unless @thang?.currentEvents
for event in @thang.currentEvents
continue unless event.startsWith 'text-'
continue if @handledDisplayEvents[event]
@handledDisplayEvents[event] = true
options = JSON.parse(event[5...])
label = new createjs.Text options.text, "bold #{options.size or 16}px Arial", options.color or '#FFF'
shadowColor = {humans: '#F00', ogres: '#00F', neutral: '#0F0', common: '#0F0'}[@thang.team] ? '#000'
label.shadow = new createjs.Shadow shadowColor, 1, 1, 3
offset = @getOffset 'aboveHead'
[label.x, label.y] = [@imageObject.x + offset.x - label.getMeasuredWidth() / 2, @imageObject.y + offset.y]
@options.textLayer.addChild label
window.labels ?= []
window.labels.push label
label.alpha = 0
createjs.Tween.get(label)
.to({y: label.y-2, alpha: 1}, 200, createjs.Ease.linear)
.to({y: label.y-12}, 1000, createjs.Ease.linear)
.to({y: label.y-22, alpha: 0}, 1000, createjs.Ease.linear)
.call =>
return if @destroyed
@options.textLayer.removeChild label
getBobOffset: ->
return 0 unless @thang.bobHeight

View file

@ -129,16 +129,16 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
@container.addChild children...
if @transformStyle is LayerAdapter.TRANSFORM_SURFACE_TEXT
for child in children
child.scaleX /= @scaleX
child.scaleY /= @scaleY
child.scaleX /= @container.scaleX
child.scaleY /= @container.scaleY
removeChild: (children...) ->
@container.removeChild children...
# TODO: Do we actually need to scale children that were removed?
if @transformStyle is LayerAdapter.TRANSFORM_SURFACE_TEXT
for child in children
child.scaleX *= @scaleX
child.scaleY *= @scaleY
child.scaleX *= @container.scaleX
child.scaleY *= @container.scaleY
#- Adding, removing children for WebGL layers.