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

2017/6/13

How would you use greenfoot's drawLine?

Katht99 Katht99

2017/6/13

#
In my code i tried
1
2
GreenfootImage line = new GreenfootImage();
line.drawLine(99,526,105,527);
but when I run it in my program nothing shows up.
danpost danpost

2017/6/13

#
There is no GreenfootImage constructor with no parameters. Even if you were to draw a line on the 'line' image, you will not be able to see it until you assign 'line' to an actor or draw 'line' onto an image that is already displayed in your world (on an image of another actor or on the world background image. In a new scenario, you could try the above code, changing the first line to:
1
GreenfootImage line = getBackground();
However, 'line' is not as appropriate a name as 'bg' or 'background' might be. Oh, with the above, you will need to set the drawing color of the background image by inserting something like the following between the two lines:
1
line.setColor(Color.BLACK);
Katht99 Katht99

2017/6/13

#
Oh okay thank you
You need to login to post a reply.