Fixed sprite coloring and the thangtype-not-yet-loaded placeholder.

This commit is contained in:
Scott Erickson 2014-09-26 12:17:46 -07:00
parent 6f45eee81d
commit c1e7423a64
2 changed files with 9 additions and 2 deletions

View file

@ -61,6 +61,9 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
super()
@options = _.extend($.extend(true, {}, @options), options)
@setThang @options.thang
if @thang?
options = @thang?.getSpriteOptions?()
@options.colorConfig = options.colorConfig if options.colorConfig
console.error @toString(), 'has no ThangType!' unless @thangType
# this is a stub, use @setImageObject to swap it out for something else later
@ -138,6 +141,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
return @hide() unless action.animation or action.container or action.relatedActions
@show()
return @updateActionDirection() unless action.animation or action.container
return if @imageObject.placeholder
m = if action.container then 'gotoAndStop' else 'gotoAndPlay'
@imageObject[m]?(action.name)
@updateScale()

View file

@ -441,8 +441,11 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
if not cocoSprite.thangType.isFullyLoaded()
# just give a placeholder
sprite = new createjs.Sprite(@spriteSheet)
sprite.gotoAndStop(0)
sprite.placeholder = true
sprite.baseScaleX = sprite.baseScaleY = 1
sprite.regX = @resolutionFactor * SPRITE_PLACEHOLDER_WIDTH / 2
sprite.regY = @resolutionFactor * SPRITE_PLACEHOLDER_WIDTH
sprite.baseScaleX = sprite.baseScaleY = sprite.scaleX = sprite.scaleY = 10 / (@resolutionFactor * SPRITE_PLACEHOLDER_WIDTH)
else if cocoSprite.thangType.get('raster')
sprite = new createjs.Sprite(@spriteSheet)
@ -455,7 +458,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
else
SpriteClass = if (cocoSprite.thangType.get('spriteType') or @defaultSpriteType) is 'segmented' then SegmentedSprite else SingularSprite
prefix = @renderGroupingKey(cocoSprite.thangType, null, cocoSprite.colorConfig) + '.'
prefix = @renderGroupingKey(cocoSprite.thangType, null, cocoSprite.options.colorConfig) + '.'
sprite = new SpriteClass(@spriteSheet, cocoSprite.thangType, prefix, @resolutionFactor)
sprite.sprite = cocoSprite