Do not cover the piece with the finger on mobile
This commit is contained in:
parent
206b93968f
commit
d31991a7af
2 changed files with 13 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue