Fixed issues with initial sprite scaling.

This commit is contained in:
Nick Winter 2014-05-19 10:39:18 -07:00
parent b8e6e49a8d
commit 5dd8bec393
2 changed files with 12 additions and 5 deletions

View file

@ -84,14 +84,18 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
AudioPlayer.preloadSoundReference sound for sound in sounds
@stillLoading = false
if @thangType.get('raster')
@actions = {}
@isRaster = true
@setUpRasterImage()
@actions = {}
else
@actions = @thangType.getActions()
@buildFromSpriteSheet @buildSpriteSheet()
@createMarks()
finishSetup: ->
return unless @thang
@update true # Reflect initial scale and other state
setUpRasterImage: ->
raster = @thangType.get('raster')
image = new createjs.Bitmap('/file/'+raster)
@ -106,7 +110,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
reg = @getOffset 'registration'
@imageObject.regX = -reg.x
@imageObject.regY = -reg.y
@updateScale()
@finishSetup()
destroy: ->
mark.destroy() for name, mark of @marks
@ -150,6 +154,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
@imageObject.layerPriority = @thangType.get 'layerPriority'
@imageObject.name = @thang?.spriteName or @thangType.get 'name'
@imageObject.on 'animationend', @playNextAction
@finishSetup()
##################################################
# QUEUEING AND PLAYING ACTIONS
@ -251,7 +256,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
return if @destroyed
@options.groundLayer.removeChild circle
delete @handledDisplayEvents[event]
showTextEvents: ->
return unless @thang?.currentEvents
for event in @thang.currentEvents
@ -342,6 +347,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
scaleX *= scale
scaleY *= scale
console.error "No thang for", @ unless @thang
scaleFactorX = @thang.scaleFactorX ? @scaleFactor
scaleFactorY = @thang.scaleFactorY ? @scaleFactor
@imageObject.scaleX = @originalScaleX * scaleX * scaleFactorX

View file

@ -29,10 +29,9 @@ module.exports = class WizardSprite extends IndieSprite
'right': 'onMoveKey'
constructor: (thangType, options) ->
if options?.isSelf
if @isSelf = options.isSelf
options.colorConfig = $.extend(true, {}, me.get('wizard')?.colorConfig) or {}
super thangType, options
@isSelf = options.isSelf
@targetPos = @thang.pos
if @isSelf
@setNameLabel me.displayName()
@ -40,6 +39,8 @@ module.exports = class WizardSprite extends IndieSprite
else if options.name
@setNameLabel options.name
finishSetup: -> # No initial setup update needed.
makeIndieThang: (thangType, thangID, pos) ->
thang = super thangType, thangID, pos
thang.isSelectable = false