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

4 days ago

Working with Colors

Proprogrammer04 Proprogrammer04

4 days ago

#
I tryed to work with Colors, but I don't seem to get it... What do you need to import or write, so that it works? Please help(!)
danpost danpost

4 days ago

#
Use:
import greenfoot.*;
(which you probably already have). Do not use:
import java.awt.Color;
or anything similar.
Proprogrammer04 Proprogrammer04

4 days ago

#
import greenfoot.*;
Is already in the code, but if I just weite something like:
Color(255;0;0);
It does not work...
danpost danpost

3 days ago

#
Proprogrammer04 wrote...
if I just weite something like:
Color(255;0;0);
It does not work...
Use commas instead of semicolons.
Proprogrammer04 Proprogrammer04

2 days ago

#
I corrected that, but it still doesn't accept the Code. I watched a tutorial About this, and there he wrote something like:
    public void act() 
    {
        GreenfootImage draw = new GreenfootImage(100,100);
        draw.setColor(Color.BLUE);
        draw.drawLine(400,450,500,450);
        setImage(draw);
    }    
But if I run the Scenario, the line does not appear anywear on the screen... (The World is 900 by 900)
Proprogrammer04 Proprogrammer04

2 days ago

#
I red an discussion about a similar problem, and the line shows up by now. Still there is the Problem with the Color...
Super_Hippo Super_Hippo

yesterday

#
Your image has a width of 100 and a height of 100. Your line is outside the image and therefore not visible.
Proprogrammer04 Proprogrammer04

yesterday

#
The Image is there, I can see a White line and ist doing what I want it to do, but it's White...
Super_Hippo Super_Hippo

yesterday

#
Again, you have an image which has the size 100/100. You have to draw inside this image (0..99 for x and y) if you want to see it. You draw from (400|450) to (500|450) which is outside the image. Imagine you have a piece of paper lying on a desk. If you draw on the desk, then it won't be visible on the paper.
You need to login to post a reply.