mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-01 16:33:38 -04:00
Merge branch 'feature/thangload'
This commit is contained in:
commit
a1474652f6
1 changed files with 7 additions and 1 deletions
|
@ -91,6 +91,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
setUpRasterImage: ->
|
setUpRasterImage: ->
|
||||||
raster = @thangType.get('raster')
|
raster = @thangType.get('raster')
|
||||||
sprite = @imageObject = new createjs.Bitmap('/file/'+raster)
|
sprite = @imageObject = new createjs.Bitmap('/file/'+raster)
|
||||||
|
$(sprite.image).one 'load', => @updateScale?()
|
||||||
@displayObject.addChild(sprite)
|
@displayObject.addChild(sprite)
|
||||||
@configureMouse()
|
@configureMouse()
|
||||||
@originalScaleX = sprite.scaleX
|
@originalScaleX = sprite.scaleX
|
||||||
|
@ -271,9 +272,14 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
if @thangType.get('matchWorldDimensions') and @thang
|
if @thangType.get('matchWorldDimensions') and @thang
|
||||||
if @thang.width isnt @lastThangWidth or @thang.height isnt @lastThangHeight
|
if @thang.width isnt @lastThangWidth or @thang.height isnt @lastThangHeight
|
||||||
bounds = @imageObject.getBounds()
|
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.scaleX = @thang.width * Camera.PPM / bounds.width
|
||||||
@imageObject.scaleY = @thang.height * Camera.PPM * @options.camera.y2x / bounds.height
|
@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'
|
unless @thang.spriteName is 'Beam'
|
||||||
@imageObject.scaleX *= @thangType.get('scale') ? 1
|
@imageObject.scaleX *= @thangType.get('scale') ? 1
|
||||||
@imageObject.scaleY *= @thangType.get('scale') ? 1
|
@imageObject.scaleY *= @thangType.get('scale') ? 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue