From cdc999ad429c5b30fdfe180611d32da4fdeb753c Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Sat, 23 May 2020 11:02:12 +0200 Subject: [PATCH] Added option to Pan using tile coordinates. Fixed incorrect panning. --- play/isometricprojection.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/play/isometricprojection.go b/play/isometricprojection.go index 4a18b0c..b731cdd 100644 --- a/play/isometricprojection.go +++ b/play/isometricprojection.go @@ -83,7 +83,12 @@ func (p *IsometricProjection) MoveCenterTo(tile geom.PointF32) { // Pan translates the center of the projection with the given delta in view coordinates. func (p *IsometricProjection) Pan(delta geom.PointF32) { - p.MoveCenterTo(p.center.Add(delta.Mul(p.zoomInverse))) + p.PanTile(p.ViewToTileRelative(delta)) +} + +// PanTile translates the center of the projection with the given delta in tile coordinates. +func (p *IsometricProjection) PanTile(delta geom.PointF32) { + p.MoveCenterTo(p.center.Add(delta)) } // SetTileSize sets the size of a single tile (maximum width & height difference of its corners).