Androidでビットマップを削除するにはどうすればよいですか? 「太陽」と呼ばれるビットマップを作成しましたが、男が画面を横切って歩き終わったらすぐに「月」と呼ばれる新しいビットマップを追加したいのですが、太陽の上に作成されてしまいます。太陽のビットマップを削除しますか? これが歩く男のコードです。
switch (counter)
{
case 0:
skyRect.set(0, 0, canvas.getWidth(), 400);
canvas.drawRect(skyRect, sky);
canvas.drawBitmap(AndroidDude, changingX, (canvas.getHeight()/2 - (AndroidDude.getHeight()/2)), null);
if (changingX < canvas.getWidth())
{
changingX += 10;
}
else
{
changingX = 0;
sunChangingX = 0;
counter++;
}
grassRect.set(0, 400, canvas.getWidth(), canvas.getHeight());
canvas.drawRect(grassRect, grass);
canvas.drawBitmap(cloud, 100, 50, null);
canvas.drawBitmap(cloud, 700, 100, null);
canvas.drawBitmap(sun, (canvas.getWidth() - sun.getWidth()), 0, null);
invalidate();
break;
case 1:
//Remove sun and clouds here?
canvas.drawBitmap(moon, (canvas.getWidth() - moon.getWidth()), 0, null);
canvas.drawBitmap(AndroidDude, changingX, (canvas.getHeight()/2 - (AndroidDude.getHeight()/2)), null);
if (changingX < canvas.getWidth())
{
changingX += 10;
}
else
{
changingX = 0;
counter++;
}
grassRect.set(0, 400, canvas.getWidth(), canvas.getHeight());
canvas.drawRect(grassRect, grass);
canvas.drawBitmap(cloud, 100, 50, null);
canvas.drawBitmap(cloud, 700, 100, null);
canvas.drawBitmap(sun, sunChangingX, 0, null);
invalidate();
break;
}