哈希一个益智游戏,如何输出拼图

时间:2016-12-12 21:23:03

标签: java android

我正在制作一个哈希益智游戏。我正在使用2D数组作为游戏板,链接数量为数组中的int。我正在迭代数组两次。将保存在drawable文件夹中的图像输出到画布上的最佳方法是什么?

int gameBoard[][] = {{1, 0, 1, 0, 0}, {0, 2, 0, 0, 2}, {2, 0, 3, 0, 1}, {0, 0, 0, 0, 0}, {0, 0, 2, 0, 2}};

protected void onDraw(Canvas canvas) {
    canvas.drawColor(Color.WHITE);
    //i index of the row, there are 5 rows so loop through them all
    for (int i = 0; i < 5; i++)
        for (int R=0; 5 > R; R++) {
            //j is the position of an element in the row, we have 5.
            if (gameBoard[i][R] == 1) {
                // what here?

            }


        }
    }
}

0 个答案:

没有答案