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

2014/12/5

Need help adding text

csmith7 csmith7

2014/12/5

#
Once I add text onto the screen I remove it when it is clicked on, but then I want to know how to add another text image onto the screen through the same actor. I do not know how to add the text in one actor. Here is some of the code.
public class ToStart extends Actor
{
    public ToStart()
    {
        setImage(new  GreenfootImage("Click here to Start", 40,Color.WHITE, null));
    }

    public void act()
    {
        if (Greenfoot.mouseClicked(this))
        {
            getWorld().removeObjects(getWorld().getObjects(Instructions.class));
            getWorld().removeObjects(getWorld().getObjects(ToStart.class));
        }
    }
}
danpost danpost

2014/12/5

#
You could just set a new image to the actor instead of removing the actor from the world.
csmith7 csmith7

2014/12/5

#
what would that code look like?
danpost danpost

2014/12/5

#
Like line 5 but with a different text string.
You need to login to post a reply.