I'm trying to make the color of my actor change when it bounces off the edge. I know how to right the if part but i cant figure out how to write the code to randomly change the color. any help would be appreciated. thanks
This is what I have so far and it changes colors, but also turns my circles into uniform squares. If you have the book I'm trying to do exercise 6.34.( when planets bounce off the edge they change colors.)
private void changeColor()
{
int r = Greenfoot.getRandomNumber(255);
int g = Greenfoot.getRandomNumber(255);
int b = Greenfoot.getRandomNumber(255);
GreenfootImage image = new GreenfootImage ("Body.png");
image.setColor (new Color(r,g,b));
image.fill();
setImage (image);
}