Fixed point and region choosers in the level editor.

This commit is contained in:
Scott Erickson 2014-10-21 10:59:05 -07:00
parent cd8f5800a6
commit 7f4ac3e5d6
5 changed files with 8 additions and 5 deletions

View file

@ -121,6 +121,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
@container.regY = e.surfaceViewport.y
if @transformStyle is LayerAdapter.TRANSFORM_SURFACE_TEXT
for child in @container.children
continue if child.skipScaling
child.scaleX *= change
child.scaleY *= change
@ -130,6 +131,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
@container.addChild children...
if @transformStyle is LayerAdapter.TRANSFORM_SURFACE_TEXT
for child in children
continue if child.skipScaling
child.scaleX /= @container.scaleX
child.scaleY /= @container.scaleY

View file

@ -29,6 +29,6 @@ module.exports = class PointChooser extends CocoClass
updateShape: ->
sup = @options.camera.worldToSurface @point
@options.surfaceLayer.addChild @shape
@options.surfaceLayer.addChild @shape unless @shape.parent
@shape.x = sup.x
@shape.y = sup.y

View file

@ -59,10 +59,11 @@ module.exports = class RegionChooser extends CocoClass
updateShape: ->
rect = @options.camera.normalizeBounds([@firstPoint, @secondPoint])
@options.normalStage.removeChild @shape if @shape
@options.surfaceLayer.removeChild @shape if @shape
@shape = new createjs.Shape()
@shape.alpha = 0.5
@shape.mouseEnabled = false
@shape.graphics.beginFill('#fedcba').drawRect rect.x, rect.y, rect.width, rect.height
@shape.graphics.endFill()
@options.normalStage.addChild(@shape)
@shape.skipScaling = true
@options.surfaceLayer.addChild(@shape)

View file

@ -135,7 +135,7 @@ module.exports = Surface = class Surface extends CocoClass
@coordinateDisplay ?= new CoordinateDisplay camera: @camera, layer: @surfaceTextLayer if showCoordinates
hookUpChooseControls: ->
chooserOptions = stage: @normalStage, normalStage: @normalStage, camera: @camera, restrictRatio: @options.choosing is 'ratio-region'
chooserOptions = stage: @webGLStage, surfaceLayer: @surfaceTextLayer, camera: @camera, restrictRatio: @options.choosing is 'ratio-region'
klass = if @options.choosing is 'point' then PointChooser else RegionChooser
@chooser = new klass chooserOptions

View file

@ -370,7 +370,7 @@ module.exports = class ThangsTabView extends CocoView
@adjustThangPos @addThangLank, thang, pos
else
@addThangLank = null
@surface.lankBoss.reallyStopMoving = false
@surface?.lankBoss.reallyStopMoving = false
createEssentialComponents: (defaultComponents) ->
physicalConfig = {pos: {x: 10, y: 10, z: 1}}