設置鼠標滑動后app停止運行是什么情況
/**
* 根據手勢方向,獲取空方快相應的相鄰位置如果存在方塊,那么進行移動
*?
* @param type
* ? ? ? ? ? ?1:上 2:下 3:左 4:右
* @param isAnim
* ? ? ? ? ? ?@param ture:有動畫 false:沒有動畫
*/
public void changeByDir(int type, boolean isAnim) {
// 獲取當前方塊的位置
GameData mNullGameData = (GameData) iv_null_ImageView.getTag();
// 根據方向,設置相應的相鄰的位置的坐標
int new_x = mNullGameData.x;
int new_y = mNullGameData.y;
if (type == 1) {// 要移動的方塊在當前空方快的
new_x++;
} else if (type == 2) {
new_x--;
} else if (type == 3) {
new_y++;
} else if (type == 4) {
new_y--;
}
// 判斷這個新坐標,是否存在
if (new_x >= 0 && new_x < iv_game_arr.length
&& new_y>=0 && new_y < iv_game_arr[0].length) {
// 存在的話,開始移動
if (isAnim) {
changeDataByImageView(iv_game_arr[new_x][new_y]);
} else {
changeDataByImageView(iv_game_arr[new_x][new_y]);
}
changeDataByImageView(iv_game_arr[new_x][new_y],isAnim);
} else {
// 什么也不做
}
2016-12-12
if (isAnim) {
changeDataByImageView(iv_game_arr[new_x][new_y]);
} else {
changeDataByImageView(iv_game_arr[new_x][new_y]);
}
changeDataByImageView(iv_game_arr[new_x][new_y],isAnim);
} else {
// 什么也不做
}
你這里多了個else
應該是:
if (isAnim) {
changeDataByImageView(iv_game_arr[new_x][new_y]);
} else {
changeDataByImageView(iv_game_arr[new_x][new_y],isAnim);
}
} else {
//什么也不做
}