I want to display message in world on event.
I have used this.
public class ImageLabel extends Actor
{
/**
* Act - do whatever the ImageLabel wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public ImageLabel()
{
GreenfootImage g=new GreenfootImage(100,20);
g.drawString("message",2,20);
setImage(g);
}
public void act()
{
// Add your action code here.
}
}
But this I do only manually.
I want to do on the event.
Event is one of the image disappears. This is my code for image disappearing
Both of the below methods are in same class.
public void act()
{
//other methods called.
pennymoved();
}
void pennymoved(){
Actor worldActorpenny = getOneIntersectingObject(Penny.class);
if (worldActorpenny != null) {
getWorld().removeObject(worldActorpenny);
}
}