mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 19:06:59 -05:00
Merge pull request #547 from jayant1992/master
Improved panning and zooming for editor
This commit is contained in:
commit
7b1f8d1114
3 changed files with 6 additions and 3 deletions
|
@ -165,6 +165,7 @@ module.exports = class Camera extends CocoClass
|
||||||
target = {x: newTargetX, y:newTargetY}
|
target = {x: newTargetX, y:newTargetY}
|
||||||
else
|
else
|
||||||
target = @target
|
target = @target
|
||||||
|
if not(newZoom >= MAX_ZOOM or newZoom <= Math.max(@minZoom, MIN_ZOOM))
|
||||||
@zoomTo target, newZoom, 0
|
@zoomTo target, newZoom, 0
|
||||||
|
|
||||||
onMouseDown: (e) ->
|
onMouseDown: (e) ->
|
||||||
|
|
|
@ -7,7 +7,6 @@ module.exports = class RegionChooser extends CocoClass
|
||||||
@options.stage.addEventListener 'stagemousedown', @onMouseDown
|
@options.stage.addEventListener 'stagemousedown', @onMouseDown
|
||||||
@options.stage.addEventListener 'stagemousemove', @onMouseMove
|
@options.stage.addEventListener 'stagemousemove', @onMouseMove
|
||||||
@options.stage.addEventListener 'stagemouseup', @onMouseUp
|
@options.stage.addEventListener 'stagemouseup', @onMouseUp
|
||||||
@options.camera.dragDisabled = true
|
|
||||||
|
|
||||||
destroy: ->
|
destroy: ->
|
||||||
@options.stage.removeEventListener 'stagemousedown', @onMouseDown
|
@options.stage.removeEventListener 'stagemousedown', @onMouseDown
|
||||||
|
@ -18,6 +17,7 @@ module.exports = class RegionChooser extends CocoClass
|
||||||
onMouseDown: (e) =>
|
onMouseDown: (e) =>
|
||||||
return unless key.shift
|
return unless key.shift
|
||||||
@firstPoint = @options.camera.canvasToWorld {x: e.stageX, y: e.stageY}
|
@firstPoint = @options.camera.canvasToWorld {x: e.stageX, y: e.stageY}
|
||||||
|
@options.camera.dragDisabled = true
|
||||||
|
|
||||||
onMouseMove: (e) =>
|
onMouseMove: (e) =>
|
||||||
return unless @firstPoint
|
return unless @firstPoint
|
||||||
|
@ -30,6 +30,7 @@ module.exports = class RegionChooser extends CocoClass
|
||||||
Backbone.Mediator.publish 'choose-region', points: [@firstPoint, @secondPoint]
|
Backbone.Mediator.publish 'choose-region', points: [@firstPoint, @secondPoint]
|
||||||
@firstPoint = null
|
@firstPoint = null
|
||||||
@secondPoint = null
|
@secondPoint = null
|
||||||
|
@options.camera.dragDisabled = false
|
||||||
|
|
||||||
restrictRegion: ->
|
restrictRegion: ->
|
||||||
RATIO = 1.56876 # 924 / 589
|
RATIO = 1.56876 # 924 / 589
|
||||||
|
|
|
@ -146,7 +146,6 @@ module.exports = class ThangsTabView extends View
|
||||||
@surface.playing = false
|
@surface.playing = false
|
||||||
@surface.setWorld @world
|
@surface.setWorld @world
|
||||||
@surface.camera.zoomTo({x:262, y:-164}, 1.66, 0)
|
@surface.camera.zoomTo({x:262, y:-164}, 1.66, 0)
|
||||||
@surface.camera.dragDisabled = true
|
|
||||||
|
|
||||||
destroy: ->
|
destroy: ->
|
||||||
@selectAddThangType null
|
@selectAddThangType null
|
||||||
|
@ -168,6 +167,7 @@ module.exports = class ThangsTabView extends View
|
||||||
|
|
||||||
onSpriteDragged: (e) ->
|
onSpriteDragged: (e) ->
|
||||||
return unless @selectedExtantThang and e.thang?.id is @selectedExtantThang?.id
|
return unless @selectedExtantThang and e.thang?.id is @selectedExtantThang?.id
|
||||||
|
@surface.camera.dragDisabled = true
|
||||||
{stageX, stageY} = e.originalEvent
|
{stageX, stageY} = e.originalEvent
|
||||||
wop = @surface.camera.canvasToWorld x: stageX, y: stageY
|
wop = @surface.camera.canvasToWorld x: stageX, y: stageY
|
||||||
wop.z = @selectedExtantThang.depth / 2
|
wop.z = @selectedExtantThang.depth / 2
|
||||||
|
@ -178,6 +178,7 @@ module.exports = class ThangsTabView extends View
|
||||||
onSpriteMouseUp: (e) ->
|
onSpriteMouseUp: (e) ->
|
||||||
clearInterval(@movementInterval) if @movementInterval?
|
clearInterval(@movementInterval) if @movementInterval?
|
||||||
@movementInterval = null
|
@movementInterval = null
|
||||||
|
@surface.camera.dragDisabled = false
|
||||||
return unless @selectedExtantThang and e.thang?.id is @selectedExtantThang?.id
|
return unless @selectedExtantThang and e.thang?.id is @selectedExtantThang?.id
|
||||||
pos = @selectedExtantThang.pos
|
pos = @selectedExtantThang.pos
|
||||||
physicalOriginal = componentOriginals["physics.Physical"]
|
physicalOriginal = componentOriginals["physics.Physical"]
|
||||||
|
|
Loading…
Reference in a new issue