为了账号安全,请及时绑定邮箱和手机立即绑定

做完之后执行不出效果

http://img1.sycdn.imooc.com//57d0fe640001ac1e08850557.jpg代码如上,看一下是什么位置出现了问题,谢谢

正在回答

3 回答

我也遇到你这个情况,我看了下代码一样。请问你解决了这个问题了吗


0 回复 有任何疑惑可以回复我~
#1

Forget_淡忘 提问者

你看看下边我的评论,具体怎么改的有点忘了...
2016-10-22 回复 有任何疑惑可以回复我~
function moveLeft() {

                            if (!canMoveLeft(board))
                                return false;

                            //moveLeft
                            for (var i = 0; i < 4; i++)
                                for (var j = 1; j < 4; j++) {
                                    if (board[i][j] != 0) {

                                        for (var k = 0; k < j; k++) {
                                            if (board[i][k] == 0 && noBlockHorizontal(i, k, j, board)) {
                                                //move
                                                showMoveAnimation(i, j, i, k);
                                                board[i][k] = board[i][j];
                                                board[i][j] = 0;
                                                continue;
                                            } else if (board[i][k] == board[i][j] && noBlockHorizontal(i, k, j, board) && !hasConflicted[i][k]) {
                                                //move
                                                showMoveAnimation(i, j, i, k);
                                                //add
                                                board[i][k] += board[i][j];
                                                board[i][j] = 0;
                                                score += board[i][k];
                                                updateScore(score);
                                                hasConflicted[i][k] = true;
                                                continue;
                                            }
                                        }
                                    }
                                }
                            setTimeout("updateBoardView()", 100);
                            return true;
                        }


0 回复 有任何疑惑可以回复我~
function moveLeft() {
	if (!canMoveLeft(board)) {
		return false;
	} else {
		for (var i = 0; i < 4; i++) {
			for (var j = 1; j < 4; j++) {
				if (board[i][j] != 0) {
					for (var k = 0; k < j; k++) {
						if (board[i][k] == 0 && noBlockHorizontal(i, k, j, board)) {
							//move
							showMoveAnimation(i, j, i, k);
							board[i][k] = board[i][j];
							board[i][j] = 0;
							continue;
						} else if (board[i][k] == board[i][j] && noBlockHorizontal(i, k, j, board)) {
							//move
							showMoveAnimation(i, j, i, k);
							//add
							board[i][k] += board[i][j];
							board[i][j] = 0;
							continue;
						}
					}
				}
			}
		}
		updateBoardView();
		return true;
	}
}


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

做完之后执行不出效果

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信