Fixed the target mark.

This commit is contained in:
Scott Erickson 2014-05-19 16:17:54 -07:00
parent 8ae14e21ae
commit 9ace31d391
2 changed files with 9 additions and 6 deletions

View file

@ -344,12 +344,12 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
angle = 180 - angle if angle > 90
scaleX = 0.5 + 0.5 * (90 - angle) / 90
console.error "No thang for", @ unless @thang
# console.error "No thang for", @ unless @thang
# TODO: support using scaleFactorX/Y from the thang object
@imageObject.scaleX = @baseScaleX * @scaleFactor * scaleX
@imageObject.scaleY = @baseScaleY * @scaleFactor * scaleY
if (@thang.scaleFactor or 1) isnt @targetScaleFactor
if @thang and (@thang.scaleFactor or 1) isnt @targetScaleFactor
createjs.Tween.removeTweens(@)
createjs.Tween.get(@).to({scaleFactor:@thang.scaleFactor or 1}, 2000, createjs.Ease.elasticOut)
@targetScaleFactor = @thang.scaleFactor or 1

View file

@ -201,7 +201,8 @@ module.exports = class Mark extends CocoClass
Backbone.Mediator.publish 'sprite:loaded'
update: (pos=null) ->
return false unless @on and @mark and @sprite?.thangType.isFullyLoaded()
return false unless @on and @mark
return false if @sprite? and not @sprite.thangType.isFullyLoaded()
@mark.visible = not @hidden
@updatePosition pos
@updateRotation()
@ -250,10 +251,12 @@ module.exports = class Mark extends CocoClass
scale = size / {selection: 128, target: 128, repair: 320, highlight: 160}[@name]
if @sprite?.thang.spriteName.search(/(dungeon|indoor).wall/i) isnt -1
scale *= 2
@mark.scaleX = @mark.scaleY = Math.min 1, scale
if @markSprite?
@mark.scaleX *= @markSprite.originalScaleX
@mark.scaleY *= @markSprite.originalScaleY
@markSprite.scaleFactor = scale
@markSprite.updateScale()
else
@mark.scaleX = @mark.scaleY = Math.min 1, scale
if @name in ['selection', 'target', 'repair']
@mark.scaleY *= @camera.y2x # code applies perspective