better touch controls!
This commit is contained in:
parent
b73d9fe1ef
commit
b4a75ff58e
1 changed files with 7 additions and 10 deletions
|
@ -79,15 +79,12 @@ namespace TouchyTickets {
|
|||
if (GameImpl.Instance.DrawMap && GameImpl.Instance.UiSystem.Controls.HandleTouch) {
|
||||
var camera = GameImpl.Instance.Camera;
|
||||
if (MlemGame.Input.GetGesture(GestureType.Pinch, out var pinch)) {
|
||||
var startDiff = pinch.Position2 - pinch.Position;
|
||||
var endDiff = pinch.Position2 + pinch.Delta2 - (pinch.Position + pinch.Delta);
|
||||
if (startDiff.LengthSquared() < endDiff.LengthSquared()) {
|
||||
// zooming in
|
||||
camera.Zoom(pinch.Delta.Length() / camera.Scale);
|
||||
} else {
|
||||
// zooming out
|
||||
camera.Zoom(-pinch.Delta.Length() / camera.Scale);
|
||||
}
|
||||
// pinch zoom
|
||||
var center = (pinch.Position + pinch.Position2) / 2;
|
||||
var newDist = Vector2.Distance(pinch.Position + pinch.Delta, pinch.Position2 + pinch.Delta2);
|
||||
var oldDist = Vector2.Distance(pinch.Position, pinch.Position2);
|
||||
var newScale = newDist / oldDist * camera.Scale;
|
||||
camera.Zoom(newScale - camera.Scale, center);
|
||||
} else if (MlemGame.Input.GetGesture(GestureType.FreeDrag, out var drag)) {
|
||||
if (this.draggingAttraction) {
|
||||
// move the current placing position
|
||||
|
@ -98,7 +95,7 @@ namespace TouchyTickets {
|
|||
this.PlacingPosition = nextPos;
|
||||
} else {
|
||||
// move the camera
|
||||
camera.Position -= drag.Delta / camera.Scale;
|
||||
camera.Position -= drag.Delta / camera.ActualScale;
|
||||
}
|
||||
} else if (this.PlacingAttraction != null) {
|
||||
foreach (var touch in MlemGame.Input.TouchState) {
|
||||
|
|
Loading…
Reference in a new issue