Fixed some issues with the thang editor.

This commit is contained in:
Scott Erickson 2014-09-30 13:34:44 -07:00
parent 8f29d0ee7f
commit b3ae258bed

View file

@ -122,6 +122,7 @@ module.exports = class ThangTypeEditView extends RootView
canvas = @$el.find('#canvas') canvas = @$el.find('#canvas')
@stage = new createjs.Stage(canvas[0]) @stage = new createjs.Stage(canvas[0])
@layerAdapter = new LayerAdapter({name:'Default', webGL: true}) @layerAdapter = new LayerAdapter({name:'Default', webGL: true})
@listenTo @layerAdapter, 'new-spritesheet', @onNewSpriteSheet
@stage.addChild(@layerAdapter.container) @stage.addChild(@layerAdapter.container)
@camera?.destroy() @camera?.destroy()
@camera = new Camera canvas @camera = new Camera canvas
@ -228,15 +229,10 @@ module.exports = class ThangTypeEditView extends RootView
# animation select # animation select
refreshAnimation: => refreshAnimation: =>
@thangType.buildActions()
return @showRasterImage() if @thangType.get('raster') return @showRasterImage() if @thangType.get('raster')
options = @getLankOptions() options = @getLankOptions()
console.log 'refresh animation....' console.log 'refresh animation....'
# @thangType.resetSpriteSheetCache()
# spriteSheet = @thangType.buildSpriteSheet(options)
# $('#spritesheets').empty()
# return unless spriteSheet
# for image in spriteSheet._images
# $('#spritesheets').append(image)
@showAnimation() @showAnimation()
@updatePortrait() @updatePortrait()
@ -246,6 +242,12 @@ module.exports = class ThangTypeEditView extends RootView
@currentLank = sprite @currentLank = sprite
@showSprite(sprite.sprite) @showSprite(sprite.sprite)
@updateScale() @updateScale()
onNewSpriteSheet: ->
$('#spritesheets').empty()
for image in @layerAdapter.spriteSheet._images
$('#spritesheets').append(image)
@updateScale()
showAnimation: (animationName) -> showAnimation: (animationName) ->
animationName = @$el.find('#animations-select').val() unless _.isString animationName animationName = @$el.find('#animations-select').val() unless _.isString animationName
@ -334,8 +336,8 @@ module.exports = class ThangTypeEditView extends RootView
@scale = scaleValue @scale = scaleValue
@$el.find('.scale-label').text " #{fixed}x " @$el.find('.scale-label').text " #{fixed}x "
if @currentLank if @currentLank
@currentLank.scaleFactorX = @currentLank.scaleFactorY = scaleValue @currentLank.sprite.scaleX = @currentLank.sprite.baseScaleX * scaleValue
@currentLank.updateScale() @currentLank.sprite.scaleY = @currentLank.sprite.baseScaleY * scaleValue
else if @currentObject? else if @currentObject?
@currentObject.scaleX = @currentObject.scaleY = scaleValue / resValue @currentObject.scaleX = @currentObject.scaleY = scaleValue / resValue
@updateGrid() @updateGrid()