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