Fixed mouse scrolling. Fixed SpriteStage scaling (scale the layers instead). Added spriteType to the ThangType schema.

This commit is contained in:
Scott Erickson 2014-09-26 11:07:01 -07:00
parent 8aeb6555ec
commit 627c56dbb5
5 changed files with 15 additions and 5 deletions

View file

@ -62,6 +62,7 @@ module.exports = class Camera extends CocoClass
onResize: (newCanvasWidth, newCanvasHeight) ->
@canvasScaleFactorX = newCanvasWidth / @canvasWidth
@canvasScaleFactorY = newCanvasHeight / @canvasHeight
Backbone.Mediator.publish 'camera:zoom-updated', camera: @, zoom: @zoom, surfaceViewport: @surfaceViewport
calculateViewingAngle: (angle) ->
# Operate on open interval between 0 - 90 degrees to make the math easier

View file

@ -114,6 +114,9 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
if @transformStyle in [LayerAdapter.TRANSFORM_SURFACE, LayerAdapter.TRANSFORM_SURFACE_TEXT, LayerAdapter.TRANSFORM_CHILD]
change = @container.scaleX / e.zoom
@container.scaleX = @container.scaleY = e.zoom
if @webGL
@container.scaleX *= @camera.canvasScaleFactorX
@container.scaleY *= @camera.canvasScaleFactorY
@container.regX = e.surfaceViewport.x
@container.regY = e.surfaceViewport.y
if @transformStyle is LayerAdapter.TRANSFORM_SURFACE_TEXT

View file

@ -120,7 +120,7 @@ module.exports = Surface = class Surface extends CocoClass
@webGLStage.addEventListener 'stagemousemove', @onMouseMove
@webGLStage.addEventListener 'stagemousedown', @onMouseDown
@webGLCanvas[0].addEventListener 'mouseup', @onMouseUp
@webGLStage.on 'mousewheel', @onMouseWheel
@webGLCanvas.on 'mousewheel', @onMouseWheel
@hookUpChooseControls() if @options.choosing # TODO: figure this stuff out
createjs.Ticker.timingMode = createjs.Ticker.RAF_SYNCHED
createjs.Ticker.setFPS @options.frameRate
@ -522,10 +522,14 @@ module.exports = Surface = class Surface extends CocoClass
#@normalCanvas.height newHeight
scaleFactor = if application.isIPadApp then 2 else 1 # Retina
@normalCanvas.add(@webGLCanvas).attr width: newWidth * scaleFactor, height: newHeight * scaleFactor
@webGLStage.scaleX = @normalStage.scaleX *= newWidth / oldWidth
@webGLStage.scaleY = @normalStage.scaleY *= newHeight / oldHeight
# Cannot do this to the webGLStage because it does not use scaleX/Y.
# Instead the LayerAdapter scales webGL-enabled layers.
@webGLStage.updateViewport(@webGLCanvas[0].width, @webGLCanvas[0].height)
@normalStage.scaleX *= newWidth / oldWidth
@normalStage.scaleY *= newHeight / oldHeight
@camera.onResize newWidth, newHeight
#- Camera focus on hero
focusOnHero: ->
@ -695,7 +699,7 @@ module.exports = Surface = class Surface extends CocoClass
@normalStage.enableDOMEvents false
@webGLStage.enableDOMEvents false
@webGLStage.enableMouseOver 0
@webGLStage.off 'mousewheel', @onMouseWheel
@webGLCanvas.off 'mousewheel', @onMouseWheel
$(window).off 'resize', @onResize
clearTimeout @surfacePauseTimeout if @surfacePauseTimeout
clearTimeout @surfaceZoomPauseTimeout if @surfaceZoomPauseTimeout

View file

@ -123,6 +123,7 @@ _.extend ThangTypeSchema.properties,
scale:
title: 'Scale'
type: 'number'
spriteType: { enum: ['singular', 'segmented'], title: 'Sprite Type' }
positions: PositionsSchema
raster: {type: 'string', format: 'image-file', title: 'Raster Image'}
rasterIcon: { type: 'string', format: 'image-file', title: 'Raster Image Icon' }

View file

@ -33,6 +33,7 @@ ThangTypeHandler = class ThangTypeHandler extends Handler
'kind'
'raster'
'rasterIcon'
'spriteType'
]
hasAccess: (req) ->