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

2017/4/7

i cant get the colours working it keeps show an error every time i put it in, Any help would be very much appreciated!

S77 S77

2017/4/7

#
setImage(new GreenfootImage(healthBarWidth + 2, healthBarHeight + 2)); GreenfootImage myImage = getImage(); myImage.setColor(Color.WHITE); myImage.drawRect(0, 0, healthBarWidth + 1, healthBarHeight + 1);
danpost danpost

2017/4/7

#
Try adding or removing this line:
1
import java.awt.Color;
Nosson1459 Nosson1459

2017/4/7

#
danpost wrote...
Try adding or removing this line:
1
import java.awt.Color;
The reason for saying "adding or removing" is probably because you didn't say what the error is, which makes it harder to help. If you're using Greenfoot Version 3.1.0 then you shouldn't have that line in your code, but if you have an earlier version then you need that line to use colors. All this might not help at all since you didn't say the error.
S77 S77

2017/4/7

#
when ever i add a color with the code myImage.setColor(Color.WHITE); it always seems to be the color that has the error line underneath it. i also did add the import java.awt.Color; Before! using 3.1.0
Nosson1459 Nosson1459

2017/4/7

#
You still didn't say what the error is, but if you're using 3.1.0 then you should NOT have that import. If you want to keep the import then do "greenfoot.Color.WHITE".
S77 S77

2017/4/7

#
oh i must be retarded, i took your advise anyway and i worked thanks!
Nosson1459 Nosson1459

2017/4/7

#
S77 wrote...
oh i must be retarded
I wouldn't know, but I don't think that asking a question titles someone as retarded.
danpost danpost

2017/4/7

#
S77 wrote...
i took your advise anyway and i worked thanks!
You probably do not have this import then:
1
import greenfoot.*;
which would allow you to use 'Color.WHITE' instead of 'greenfoot.Color.WHITE'.
You need to login to post a reply.