Reputation: 1925
I am trying to make a simple game where, i want to have 5 bitmaps in surface view and they are shown and hidden randomly .As i have placed all bitmaps, now how to hide and show bitmaps In surface view randomly. I do not want to have a layer above those bitmap as my background is moving
Upvotes: 0
Views: 996
Reputation: 382
generate 5 random numbers from 0 - 1
int randomOne = (int) ((Math.random()); //repeat this 4 more times
within your canvas, choose to draw or not draw those bitmaps because of the random number selected
if (randomOne == 1)
{
canvas.drawBitmap((Bitmap)bitmapName,x,y,null);
}
//repeat this 4 more times
if you wish to constantly change whether or not these bitmaps are shown, use a timer
Upvotes: 1