+ 9
[SOLVED]How to change the background color
I will like to change the background color whenever the ball hits the edge of the canvas. I tried something but it didn't work. https://code.sololearn.com/W9R6A4FG86aj/?ref=app
6 Respuestas
+ 2
https://code.sololearn.com/WhnEjXAWzNx2/?ref=app
+ 3
Taste thanks a lot...
+ 2
It change actually, but only in the single frame or less. When the ball reach the edge.
Your background(100) at line 11 is the one cause the problem. Because it'll always draw what ever the case.
To do this, simply put the background value in a variable. Then draw the background using that variable. You can change this variable to change the background color
+ 2
Thats kind of not what i meant.
My suggestion is store the value in a variable, just like speed.
var bgcolor = 100;
Then draw the background using that variable
background(bgcolor);
To change the color, just change the value of that variable
bgcolor = newcolor;
0
Really how could you teach me?