This site requires JavaScript, please enable it in your browser!
Greenfoot back
Antoine
Antoine wrote ...

2019/4/24

how do i get the color to be imported to greenfoot color

Antoine Antoine

2019/4/24

#
i can't get greenfoot to accept the color i'm importing The code below is the code i'm using if someone has a different code layout which works, could you possibly paste the code in the comment part thanks ps. this would help me with my course work import greenfoot.*; import java.awt.Color; public class Counter extends Actor { private int value= 0; public void act(){ setImage(new GreenfootImage("Score: "+value, 20, Color.WHITE, Color.BLUE)); if(value==100) { Won(); Greenfoot.stop(); } } public void Value(int newValue) { value++; } public void Won() { Won won = new Won(); Greenfoot.setWorld(won); } }
Super_Hippo Super_Hippo

2019/4/24

#
Remove this line:
import java.awt.Color;
Antoine Antoine

2019/4/24

#
hey man, have just done it now works and i don't know why it was not working before and thank you for you help
Antoine Antoine

2019/4/24

#
Super_Hippo thank you so much for your help witch now can an able me to get my course work in
Super_Hippo Super_Hippo

2019/4/24

#
The Greenfoot package has a Color class (Greenfoot.Color) which you import when importing greenfoot.*. If you import java.awt.Color, you use this Color class instead. The GreenfootImage constructor requires the Greenfoot.Color class. This was changed to make conversions to HTML5 possible for exported scenarios.
You need to login to post a reply.