Skip to content

Commit b2e24b7

Browse files
committed
Made the undo and new game buttons easier to press.
1 parent 87866a2 commit b2e24b7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

2048/2048/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
defaultConfig {
88
minSdkVersion 7
99
targetSdkVersion 22
10-
versionCode 22
11-
versionName "1.1.6"
10+
versionCode 23
11+
versionName "1.1.7"
1212
}
1313
buildTypes {
1414
release {

2048/2048/src/main/java/com/tpcstld/twozerogame/InputListener.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ class InputListener implements View.OnTouchListener {
2222
private float startingY;
2323
private int previousDirection = 1;
2424
private int veryLastDirection = 1;
25+
// Whether or not we have made a move, i.e. the blocks shifted or tried to shift.
2526
private boolean hasMoved = false;
27+
// Whether or not we began the press on an icon. This is to disable swipes if the user began
28+
// the press on an icon.
29+
private boolean beganOnIcon = false;
2630

2731
public InputListener(MainView view) {
2832
super();
@@ -42,11 +46,13 @@ public boolean onTouch(View view, MotionEvent event) {
4246
lastDx = 0;
4347
lastDy = 0;
4448
hasMoved = false;
49+
beganOnIcon = iconPressed(mView.sXNewGame, mView.sYIcons)
50+
|| iconPressed(mView.sXUndo, mView.sYIcons);
4551
return true;
4652
case MotionEvent.ACTION_MOVE:
4753
x = event.getX();
4854
y = event.getY();
49-
if (mView.game.isActive()) {
55+
if (mView.game.isActive() && !beganOnIcon) {
5056
float dx = x - previousX;
5157
if (Math.abs(lastDx + dx) < Math.abs(lastDx) + Math.abs(dx) && Math.abs(dx) > RESET_STARTING
5258
&& Math.abs(x - startingX) > SWIPE_MIN_DISTANCE) {
@@ -154,6 +160,6 @@ private boolean inRange(float starting, float check, float ending) {
154160
}
155161

156162
private boolean isTap(int factor) {
157-
return pathMoved() <= mView.iconSize * factor;
163+
return pathMoved() <= mView.iconSize * mView.iconSize * factor;
158164
}
159165
}

0 commit comments

Comments
 (0)