views:

62

answers:

1

My loadMap() method generate a canvas.throwIfRecycled exception when i try to load a new map.
When i start the game, the initial map loads and work fine though,
its only when i try to load a new map that i get the exception ..

how can i "reset" canvas and the bitmap i use to draw into, so i can startover fresh with them ?
here's what i use to create and draw my maps:

picDest = Bitmap.createBitmap(width*tileSize, height*tileSize, Bitmap.Config.RGB_565);
canvas = new Canvas(picDest);
for (int y = 0; y < height; y++) {
  for (int x = 0; x < width; x++) {
    // process tile stuffs here ...
    /*
    col = ....:
    row = ....;
    */
    pic[x][y]= Bitmap.createBitmap(sheet, col*tileSize, row*tileSize, tileSize, tileSize);
    canvas.drawBitmap(pic[x][y],x*tileSize,y*tileSize,bitmPaint); 
  }
}

so basicaly once i created and used picDest and canvas,
i cannot figure how to reset it all for when i want to load a new map..

tnx

A: 

If you call invalidate(); it'll redraw (therefore reseting it, and following any new instructions to draw whatever).

xil3