mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-24 19:59:53 -04:00
Fixed issues with initial sprite scaling.
This commit is contained in:
parent
b8e6e49a8d
commit
5dd8bec393
2 changed files with 12 additions and 5 deletions
|
@ -84,14 +84,18 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
AudioPlayer.preloadSoundReference sound for sound in sounds
|
AudioPlayer.preloadSoundReference sound for sound in sounds
|
||||||
@stillLoading = false
|
@stillLoading = false
|
||||||
if @thangType.get('raster')
|
if @thangType.get('raster')
|
||||||
|
@actions = {}
|
||||||
@isRaster = true
|
@isRaster = true
|
||||||
@setUpRasterImage()
|
@setUpRasterImage()
|
||||||
@actions = {}
|
|
||||||
else
|
else
|
||||||
@actions = @thangType.getActions()
|
@actions = @thangType.getActions()
|
||||||
@buildFromSpriteSheet @buildSpriteSheet()
|
@buildFromSpriteSheet @buildSpriteSheet()
|
||||||
@createMarks()
|
@createMarks()
|
||||||
|
|
||||||
|
finishSetup: ->
|
||||||
|
return unless @thang
|
||||||
|
@update true # Reflect initial scale and other state
|
||||||
|
|
||||||
setUpRasterImage: ->
|
setUpRasterImage: ->
|
||||||
raster = @thangType.get('raster')
|
raster = @thangType.get('raster')
|
||||||
image = new createjs.Bitmap('/file/'+raster)
|
image = new createjs.Bitmap('/file/'+raster)
|
||||||
|
@ -106,7 +110,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
reg = @getOffset 'registration'
|
reg = @getOffset 'registration'
|
||||||
@imageObject.regX = -reg.x
|
@imageObject.regX = -reg.x
|
||||||
@imageObject.regY = -reg.y
|
@imageObject.regY = -reg.y
|
||||||
@updateScale()
|
@finishSetup()
|
||||||
|
|
||||||
destroy: ->
|
destroy: ->
|
||||||
mark.destroy() for name, mark of @marks
|
mark.destroy() for name, mark of @marks
|
||||||
|
@ -150,6 +154,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
@imageObject.layerPriority = @thangType.get 'layerPriority'
|
@imageObject.layerPriority = @thangType.get 'layerPriority'
|
||||||
@imageObject.name = @thang?.spriteName or @thangType.get 'name'
|
@imageObject.name = @thang?.spriteName or @thangType.get 'name'
|
||||||
@imageObject.on 'animationend', @playNextAction
|
@imageObject.on 'animationend', @playNextAction
|
||||||
|
@finishSetup()
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
# QUEUEING AND PLAYING ACTIONS
|
# QUEUEING AND PLAYING ACTIONS
|
||||||
|
@ -251,7 +256,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
return if @destroyed
|
return if @destroyed
|
||||||
@options.groundLayer.removeChild circle
|
@options.groundLayer.removeChild circle
|
||||||
delete @handledDisplayEvents[event]
|
delete @handledDisplayEvents[event]
|
||||||
|
|
||||||
showTextEvents: ->
|
showTextEvents: ->
|
||||||
return unless @thang?.currentEvents
|
return unless @thang?.currentEvents
|
||||||
for event in @thang.currentEvents
|
for event in @thang.currentEvents
|
||||||
|
@ -342,6 +347,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
scaleX *= scale
|
scaleX *= scale
|
||||||
scaleY *= scale
|
scaleY *= scale
|
||||||
|
|
||||||
|
console.error "No thang for", @ unless @thang
|
||||||
scaleFactorX = @thang.scaleFactorX ? @scaleFactor
|
scaleFactorX = @thang.scaleFactorX ? @scaleFactor
|
||||||
scaleFactorY = @thang.scaleFactorY ? @scaleFactor
|
scaleFactorY = @thang.scaleFactorY ? @scaleFactor
|
||||||
@imageObject.scaleX = @originalScaleX * scaleX * scaleFactorX
|
@imageObject.scaleX = @originalScaleX * scaleX * scaleFactorX
|
||||||
|
|
|
@ -29,10 +29,9 @@ module.exports = class WizardSprite extends IndieSprite
|
||||||
'right': 'onMoveKey'
|
'right': 'onMoveKey'
|
||||||
|
|
||||||
constructor: (thangType, options) ->
|
constructor: (thangType, options) ->
|
||||||
if options?.isSelf
|
if @isSelf = options.isSelf
|
||||||
options.colorConfig = $.extend(true, {}, me.get('wizard')?.colorConfig) or {}
|
options.colorConfig = $.extend(true, {}, me.get('wizard')?.colorConfig) or {}
|
||||||
super thangType, options
|
super thangType, options
|
||||||
@isSelf = options.isSelf
|
|
||||||
@targetPos = @thang.pos
|
@targetPos = @thang.pos
|
||||||
if @isSelf
|
if @isSelf
|
||||||
@setNameLabel me.displayName()
|
@setNameLabel me.displayName()
|
||||||
|
@ -40,6 +39,8 @@ module.exports = class WizardSprite extends IndieSprite
|
||||||
else if options.name
|
else if options.name
|
||||||
@setNameLabel options.name
|
@setNameLabel options.name
|
||||||
|
|
||||||
|
finishSetup: -> # No initial setup update needed.
|
||||||
|
|
||||||
makeIndieThang: (thangType, thangID, pos) ->
|
makeIndieThang: (thangType, thangID, pos) ->
|
||||||
thang = super thangType, thangID, pos
|
thang = super thangType, thangID, pos
|
||||||
thang.isSelectable = false
|
thang.isSelectable = false
|
||||||
|
|
Loading…
Add table
Reference in a new issue