Center camera when level loaded in level editor.
This commit is contained in:
parent
5b57fa5c71
commit
6eb23349d0
1 changed files with 11 additions and 1 deletions
|
@ -167,7 +167,17 @@ module.exports = class ThangsTabView extends CocoView
|
||||||
}
|
}
|
||||||
@surface.playing = false
|
@surface.playing = false
|
||||||
@surface.setWorld @world
|
@surface.setWorld @world
|
||||||
@surface.camera.zoomTo({x: 262, y: -164}, 1.66, 0)
|
@centerCamera()
|
||||||
|
|
||||||
|
centerCamera: ->
|
||||||
|
[width, height] = @world.size()
|
||||||
|
width = Math.max width, 80
|
||||||
|
height = Math.max height, 68
|
||||||
|
{left, top, right, bottom} = @world.getBounds()
|
||||||
|
center = x: left + width / 2, y: bottom + height / 2
|
||||||
|
sup = @surface.camera.worldToSurface center
|
||||||
|
zoom = 0.94 * 92.4 / width # Zoom 1.0 lets us see 92.4 meters.
|
||||||
|
@surface.camera.zoomTo(sup, zoom, 0)
|
||||||
|
|
||||||
destroy: ->
|
destroy: ->
|
||||||
@selectAddThangType null
|
@selectAddThangType null
|
||||||
|
|
Reference in a new issue