if (x == null_x && Math.abs(y - null_y) == 1) {
return true;
} else if (y == null_y && Math.abs(x - null_x) == 1) {
return true;
}
用绝对值的方法感觉更方便
return true;
} else if (y == null_y && Math.abs(x - null_x) == 1) {
return true;
}
用绝对值的方法感觉更方便
2016-10-05
如果把一下两行调转一下,岂不妙哉
/**
* 设置最后一个方块为空的数据
*/
setNullImageView(iv_game_arr[2][4]);
/**
* 随机打乱顺序
*/
randomMove();
/**
* 设置最后一个方块为空的数据
*/
setNullImageView(iv_game_arr[2][4]);
/**
* 随机打乱顺序
*/
randomMove();
2016-08-19
/**
* 手势的判断
*
* @param sx
* @param sy
* @param ex
* @param ey
* @return 上下左右 1 2 3 4
*/
public int getDirByGes(float sx, float sy, float ex, float ey) {
// 左右:横向距离大于竖直距离
// 左 :终点x小于起点x
// 安卓y正轴方向为竖直向下
// 上:终点y小于起点y
return Math.abs(sx-ex)<Math.abs(sy-ey)?(sy>ey?1:2):(sx>ex?3:4);
}
* 手势的判断
*
* @param sx
* @param sy
* @param ex
* @param ey
* @return 上下左右 1 2 3 4
*/
public int getDirByGes(float sx, float sy, float ex, float ey) {
// 左右:横向距离大于竖直距离
// 左 :终点x小于起点x
// 安卓y正轴方向为竖直向下
// 上:终点y小于起点y
return Math.abs(sx-ex)<Math.abs(sy-ey)?(sy>ey?1:2):(sx>ex?3:4);
}
2016-08-19