im looking to learn how to change an objects color. and how to access those different colors from another actor. im looking to switch between 2 colors and thats it heres the code i got so far
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | public class button extends Actor { Color color1 = new Color( 0 , 255 , 0 ); Color color2 = new Color( 255 , 0 , 0 ); //red Color Color = getImage().getColor(); public button(){ setImage( new GreenfootImage( 70 , 50 )); getImage().setColor(Color.RED); getImage().fillOval( 0 , 0 , 20 , 20 ); } public void act() { if ( getImage().getColor(color2) = Color.RED && Greenfoot.mouseClicked( this )){ getImage().setColor(color1); } if (getImage().Color == color1 && Greenfoot.mouseClicked( this )){ getImage().setColor(color1); } } |