Hi
I am really beginner and have no idea why if i have 2 drawings object in act method in actor class world class shows just one ? Is world class shows just one GreenfootImage object in the same time ? Smb help me pls.
Below i show code my world and actor object class.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
public void act()
{
drawFiveLine();
drawNote();
}
/**
* Draw five line on the screen
*/
public void drawFiveLine(){
GreenfootImage img = new GreenfootImage(width, high);
img.setColor(Color.WHITE);
img.fill();
img.setColor(Color.BLACK);
img.drawLine(0, 25, 475, 25);
img.drawLine(0, 35, 475, 35);
img.drawLine(0, 45, 475, 45);
img.drawLine(0, 55, 475, 55);
img.drawLine(0, 65, 475, 65);
setImage(img);
}
/**
* Draw Note
*/
public void drawNote(){
GreenfootImage note = new GreenfootImage(width,high);
note.setColor(Color.BLACK);
note.fillOval(35,80,10,10);
setImage(note);
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
public class Piano extends World
{
/**
* Constructor for objects of class Piano.
*
*/
public Piano()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(720, 480, 1);
prepare();
}
/**
* Prepare the world for the start of the program. That is: create the initial
* objects and add them to the world.
*/
private void prepare()
{
FiveLine fiveLine = new FiveLine();
addObject(fiveLine, 285,100);
}
}