Android : Generate a circle randomly on the screen and make it green or red

on Sunday, March 29, 2015


So ive been trying to make a game app that either displays a red button with text or a green button with text randomly on the android screen. If anyone can help me with this i would appreciate it. also on a side note i want to slowly generate faster cool upside if anyone knows how to do that. Thanks!



@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas){

String str = "Joke of the day";
super.onDraw(canvas);
paint = new Paint();
Random random = new Random();
Random randomTwo = new Random();

//Rect ourRect = new Rect();
Rect topRect = new Rect();
Rect backGround = new Rect();

paint.setColor(Color.BLACK);
backGround.set(0,0,canvas.getWidth(),canvas.getHeight());
canvas.drawRect(backGround, paint);
for(int i = 0; i <= 900; i++;){

}

if(blank == time){
paint.setColor(Color.RED);
canvas.drawCircle(random, randomTwo, 230, paint);
}else {
paint.setColor(Color.GREEN);
canvas.drawCircle(random, randomTwo, 230, paint);
}
}

0 comments:

Post a Comment