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

2021/2/28

how to remove the object after 3 second

mariq_rasyid29 mariq_rasyid29

2021/2/28

#
the object is strings value here the code
 Dialogue dialogue = new Dialogue("Press H for Howl");
        addObject(dialogue,179,93);
danpost danpost

2021/2/28

#
Class:
import greenfoot.*;

public TempText extends Actor
{
    private int timer;
    
    public TempText(String text, int showActs)
    {
        timer = showActs;
        setImage(new GreenfootImage(text, 28, Color.BLACK, new Color(0, 0, 0, 0)));
    }
    
    public void act()
    {
        if (--timer == 0) getWorld().removeObject(this);
    |
|
For 3 seconds, use:
addObject(new TempText("Press H for Howl", 180), 179, 93);
mariq_rasyid29 mariq_rasyid29

2021/2/28

#
thx again sir
You need to login to post a reply.