Skip to content

Commit

Permalink
Made the undo and new game buttons easier to press.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpcstld committed Feb 29, 2016
1 parent 87866a2 commit b2e24b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions 2048/2048/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 7
targetSdkVersion 22
versionCode 22
versionName "1.1.6"
versionCode 23
versionName "1.1.7"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ class InputListener implements View.OnTouchListener {
private float startingY;
private int previousDirection = 1;
private int veryLastDirection = 1;
// Whether or not we have made a move, i.e. the blocks shifted or tried to shift.
private boolean hasMoved = false;
// Whether or not we began the press on an icon. This is to disable swipes if the user began
// the press on an icon.
private boolean beganOnIcon = false;

public InputListener(MainView view) {
super();
Expand All @@ -42,11 +46,13 @@ public boolean onTouch(View view, MotionEvent event) {
lastDx = 0;
lastDy = 0;
hasMoved = false;
beganOnIcon = iconPressed(mView.sXNewGame, mView.sYIcons)
|| iconPressed(mView.sXUndo, mView.sYIcons);
return true;
case MotionEvent.ACTION_MOVE:
x = event.getX();
y = event.getY();
if (mView.game.isActive()) {
if (mView.game.isActive() && !beganOnIcon) {
float dx = x - previousX;
if (Math.abs(lastDx + dx) < Math.abs(lastDx) + Math.abs(dx) && Math.abs(dx) > RESET_STARTING
&& Math.abs(x - startingX) > SWIPE_MIN_DISTANCE) {
Expand Down Expand Up @@ -154,6 +160,6 @@ private boolean inRange(float starting, float check, float ending) {
}

private boolean isTap(int factor) {
return pathMoved() <= mView.iconSize * factor;
return pathMoved() <= mView.iconSize * mView.iconSize * factor;
}
}

0 comments on commit b2e24b7

Please sign in to comment.