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

2016/10/25

Remove Object

timguetz timguetz

2016/10/25

#
I'm trying to do a life counter in my game. I already create the counter but i don't know how to remove the pictures from the lifes in the game
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)


public class Schlange extends Mover
{
   private int Leben=3;
    
    public void act() 
    {
        if ( touches (Punkte.class) )
        { removeTouchedObject(Punkte.class);
          collectPoints (1) ;
        getWorld().neuePunkte();
        }
        if ( Greenfoot.isKeyDown("right") ) 
       
    {
     moveRight ();
     lookToTheRight ();
    }  
        if ( Greenfoot.isKeyDown("left") )
    {
     moveLeft ();
     lookToTheLeft ();
    } 
        if ( Greenfoot.isKeyDown("up") )
    {
     moveUp ();
    }    
        if ( Greenfoot.isKeyDown("down") )
    {
     moveDown ();
    }    
   if( touches(Jaeger.class))
       { Leben = Leben-1;
           setLocation(20,300);
           
        }
  if(Leben==0)
  {
getWorld().gameOver("Game Over", getScore());
    }
    if(Leben==2)
    { 
    }
    if(Leben==1)
    { 
    }
    
    }

    }
danpost danpost

2016/10/25

#
Need code of life counter and anything in your world class that deals with life counter. Also, if not deducible by the code, any information on the image(s) used for the life counter that you can provide. By the way, my Value Display Tutorial scenario discusses how to create a life counter under non-textual display of a value.
You need to login to post a reply.