Fixed adding thangs in the level editor, and moving them around.

This commit is contained in:
Scott Erickson 2014-10-01 15:02:14 -07:00
parent e9222f34bd
commit 1b1bc4e95a
3 changed files with 10 additions and 5 deletions

View file

@ -340,7 +340,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
if action.container
containersToRender[action.container] = true
else if action.animation
animationContainers = @getContainersForAnimation(thangType, action.animation)
animationContainers = @getContainersForAnimation(thangType, action.animation, action)
containersToRender[container.gn] = true for container in animationContainers
spriteBuilder = new SpriteBuilder(thangType, {colorConfig: colorConfig})
@ -355,10 +355,13 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
frame = spriteSheetBuilder.addFrame(container, null, @resolutionFactor * (thangType.get('scale') or 1))
spriteSheetBuilder.addAnimation(containerKey, [frame], false)
getContainersForAnimation: (thangType, animation) ->
containers = thangType.get('raw').animations[animation].containers
getContainersForAnimation: (thangType, animation, action) ->
rawAnimation = thangType.get('raw').animations[animation]
if not rawAnimation
console.error 'thang type', thangType.get('name'), 'is missing animation', animation, 'from action', action
containers = rawAnimation.containers
for animation in thangType.get('raw').animations[animation].animations
containers = containers.concat(@getContainersForAnimation(thangType, animation.gn))
containers = containers.concat(@getContainersForAnimation(thangType, animation.gn, action))
return containers
#- Rendering sprite sheets for singular thang types

View file

@ -98,6 +98,7 @@ module.exports = Surface = class Surface extends CocoClass
initEasel: ->
@normalStage = new createjs.Stage(@normalCanvas[0])
@webGLStage = new createjs.SpriteStage(@webGLCanvas[0])
@normalStage.nextStage = @webGLStage
@camera = AudioPlayer.camera = new Camera @webGLCanvas
@normalLayers.push @surfaceTextLayer = new Layer name: 'Surface Text', layerPriority: 1, transform: Layer.TRANSFORM_SURFACE_TEXT, camera: @camera

View file

@ -336,7 +336,7 @@ module.exports = class ThangsTabView extends CocoView
return if e? and $(e.target).closest('#thang-search').length # Ignore if you're trying to search thangs
return unless (e? and $(e.target).closest('#thangs-tab-view').length) or key.isPressed('esc') or forceDeselect
if e then target = $(e.target) else target = @$el.find('.add-thangs-palette') # pretend to click on background if no event
return true if target.attr('id') is 'surface'
return true if target.attr('id') is 'webgl-surface'
target = target.closest('.add-thang-palette-icon')
wasSelected = target.hasClass 'selected'
@$el.find('.add-thangs-palette .add-thang-palette-icon.selected').removeClass('selected')
@ -400,6 +400,7 @@ module.exports = class ThangsTabView extends CocoView
pos.y = Math.round((pos.y - (thang.height ? 1) / 2) / snap.y) * snap.y + (thang.height ? 1) / 2
pos.z = thang.depth / 2
thang.pos = pos
thang.stateChanged = true
@surface.lankBoss.update true # Make sure Obstacle layer resets cache
onSurfaceMouseMoved: (e) ->