Skip to content

Commit

Permalink
Do not cover the piece with the finger on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonami committed Feb 5, 2017
1 parent 206b939 commit d31991a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions core/src/io/github/lonamiwebs/klooni/Klooni.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down
11 changes: 9 additions & 2 deletions core/src/io/github/lonamiwebs/klooni/game/PieceHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,15 @@ public void update() {
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);
Expand Down

0 comments on commit d31991a

Please sign in to comment.