i'm making a game and i'm curious to know if i can make it so that when the player is touching an actor it will display text on the screen and if it is possible how would i do this.
// the door actor
public void touching()
{
if(isTouching(Player.class))
{
setImage("door-open.png");
if(Greenfoot.isKeyDown("enter"))
{
Greenfoot.setWorld(new Level1());
}
}else
{
setImage("door.png");
}
}
// the text actor
public void Text()
{
GreenfootImage resetText = new GreenfootImage("Level 1", 48, Color.RED, new Color(0, 0, 0, 0));
setImage(resetText);
} if(isTouching(Player.class))
{
GreenfootImage resetText = new GreenfootImage("Level 1", 48, Color.RED, new Color(0, 0, 0, 0));
setImage(resetText);
}if(isTouching(Player.class))
{
Greenfoot.drawImage L1("Level 1", color.RED);
getWorld().addObject(L1,450,450);
}else
{
Greenfoot.removeObject(L1);
}import greenfoot.*;
public class DummyClass extends Actor
{
}