From d31991a7aff6eb536713ba996b1d655f6d0b2940 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 5 Feb 2017 15:46:07 +0100 Subject: [PATCH] Do not cover the piece with the finger on mobile --- core/src/io/github/lonamiwebs/klooni/Klooni.java | 4 ++++ .../io/github/lonamiwebs/klooni/game/PieceHolder.java | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/src/io/github/lonamiwebs/klooni/Klooni.java b/core/src/io/github/lonamiwebs/klooni/Klooni.java index 684c2d6..1227fc1 100644 --- a/core/src/io/github/lonamiwebs/klooni/Klooni.java +++ b/core/src/io/github/lonamiwebs/klooni/Klooni.java @@ -1,5 +1,6 @@ package io.github.lonamiwebs.klooni; +import com.badlogic.gdx.Application; import com.badlogic.gdx.Game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Preferences; @@ -18,12 +19,15 @@ public class Klooni extends Game { public static Theme theme; public Skin skin; + public static boolean onDesktop; + //endregion //region Creation @Override public void create() { + onDesktop = Gdx.app.getType().equals(Application.ApplicationType.Desktop); prefs = Gdx.app.getPreferences("io.github.lonamiwebs.klooni.game"); // TODO Better way to have this skin somewhere diff --git a/core/src/io/github/lonamiwebs/klooni/game/PieceHolder.java b/core/src/io/github/lonamiwebs/klooni/game/PieceHolder.java index 2e0cd12..23ebb40 100644 --- a/core/src/io/github/lonamiwebs/klooni/game/PieceHolder.java +++ b/core/src/io/github/lonamiwebs/klooni/game/PieceHolder.java @@ -186,8 +186,15 @@ public class PieceHolder { Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY()); // Y axis is inverted - // Center the new piece position - mouse.sub(piece.getRectangle().width / 2, piece.getRectangle().height / 2); + if (Klooni.onDesktop) { + // Center the piece to the mouse + mouse.sub(piece.getRectangle().width * 0.5f, piece.getRectangle().height * 0.5f); + } else { + // Center the new piece position horizontally + // and push it up by it's a cell (arbitrary) vertically, thus + // avoiding to cover it with the finger (issue on Android devices) + mouse.sub(piece.getRectangle().width * 0.5f, -pickedCellSize); + } piece.pos.lerp(mouse, 0.4f); piece.cellSize = Interpolation.linear.apply(piece.cellSize, pickedCellSize, 0.4f);