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

2017/10/13

Delete Object after time?

Lennart4091 Lennart4091

2017/10/13

#
So basicly I just need the object to spawn and then dissapeer in within a couple of sceonds. No other action between this. The main part starts at line 25.
 public void fahre()
    {
        int posX = getX();
        int posY = getY();

        if(huegelVorhanden("vorne"))
        {
            nachricht("Zu steil!");
        }
        else if(getRotation()==270 && getY()==1)
        {
            nachricht("Ich kann mich nicht bewegen");
        }
        else
        {
            move(1);
            Greenfoot.delay(1);
        }

        if(posX==getX()&&posY==getY()&&!huegelVorhanden("vorne"))
        {
            nachricht("Ich kann mich nicht bewegen");
        }
        
            if(getRotation()==180)
      
    {
        getWorld().addObject(new Rauch(), (getX()+1), (getY()));
                   
            
    }
    
    if(getRotation()==0)
      
    {
        getWorld().addObject(new Rauch_Links(), (getX()-1), (getY()));
        //time
        getWorld().removeObjects(getWorld().getObjects(Rauch_Links.class));
        
    
    }    
danpost danpost

2017/10/13

#
If no other action while rauch is in world, then just use 'Greenfoot.delay' (again -- with a larger value than one; maybe 40 or so).
Lennart4091 Lennart4091

2017/10/13

#
Thank you very much for the quick answer. Good evening.
You need to login to post a reply.