mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-13 22:49:51 -04:00
Fixed raster image sprites to update their scales when they load, and to properly place themselves if matching world dimensions.
This commit is contained in:
parent
7a381df348
commit
00fdaa1d0f
1 changed files with 7 additions and 1 deletions
|
@ -91,6 +91,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
setUpRasterImage: ->
|
||||
raster = @thangType.get('raster')
|
||||
sprite = @imageObject = new createjs.Bitmap('/file/'+raster)
|
||||
$(sprite.image).one 'load', => @updateScale?()
|
||||
@displayObject.addChild(sprite)
|
||||
@configureMouse()
|
||||
@originalScaleX = sprite.scaleX
|
||||
|
@ -271,9 +272,14 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
if @thangType.get('matchWorldDimensions') and @thang
|
||||
if @thang.width isnt @lastThangWidth or @thang.height isnt @lastThangHeight
|
||||
bounds = @imageObject.getBounds()
|
||||
return unless bounds # TODO: remove this because it's a bandaid over the image sometimes not being loaded
|
||||
return unless bounds
|
||||
@imageObject.scaleX = @thang.width * Camera.PPM / bounds.width
|
||||
@imageObject.scaleY = @thang.height * Camera.PPM * @options.camera.y2x / bounds.height
|
||||
@imageObject.regX ?= 0
|
||||
@imageObject.regX += bounds.width / 2
|
||||
@imageObject.regY ?= 0
|
||||
@imageObject.regY += bounds.height / 2
|
||||
|
||||
unless @thang.spriteName is 'Beam'
|
||||
@imageObject.scaleX *= @thangType.get('scale') ? 1
|
||||
@imageObject.scaleY *= @thangType.get('scale') ? 1
|
||||
|
|
Loading…
Reference in a new issue