アセットフォルダにnewgame.txtファイルがあります。このファイルをメソッドの文字配列(cboard)で読み取りましたloadboard()
。cboard
次に、配列iの値に基づいて、のPboard
配列(ピース配列、論理配列)とbmp配列(ビットマップ配列、物理ボード)を入力しfillboard()
ます。populate()
キャンバスにビットマップ画像を描画する別の関数があります。updateBoard()
物理配列(bmp)と論理配列()の両方を更新した場所がありますPboard
。updateBoard()
論理配列を呼び出した後Pboard
、物理配列bmp
が更新されましたが、キャンバスに描画すると古い構成になります。これが私のloadboard(),fillboard(),populate
関数の呼び出しです。
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// TODO Auto-generated method stub
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
width=View.MeasureSpec.getSize(widthMeasureSpec);
height=View.MeasureSpec.getSize(heightMeasureSpec);
setMeasuredDimension(width, height);`
b=Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
c=new Canvas(b);
loadboard();
fillBoard();
calculateLinePlacement();
drawBoard();
// method draw the board and bitmap images ( call populate()).
}
updateBoard()
関数の後、私は呼び出しinvalidate()
ます;
編集1:
以下はそのupdateBoard()
方法です(commnetからコピー):
public void updateBoard(int sr, int sc, int er, int ec) {
Pboard[sr][sc] = new Empty(sr, sc, -3, "empty", board);
Pboard[er][ec] = selectedp;
Bitmap img = bmp[sr][sc];
bmp[sr][sc] = null;
bmp[er][ec] = null;
bmp[er][ec] = img;
}