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

2019/6/18

win screen

Bong_Lord Bong_Lord

2019/6/18

#
how would someone make a win screen after their player eats all enemies until enemy class is empty or they have eaten 10 enemies. all i really want is to make a new world with just text that says "you win" after player has reached their goal. the problem is not with adding the text it is just i have not been able to make this work
danpost danpost

2019/6/18

#
Which part are you having problems with -- the "win" world class code or the codes needed to trigger a new "win" world? and, what have you tried?
Bong_Lord Bong_Lord

2019/6/18

#
im having problems with making both the world and switching the game over to that world, and the code within it has no errors but whenever all enemies are dead nothing else would happen. ive tried this in a sub world
if (getObjects(Fish.class).isEmpty())//all fish get eaten then game ends
   
    {
        Greenfoot.setWorld(new YouWin());
    }
as well as this in an actor
 public void act() 
    {
        setImage(new GreenfootImage("You Win!" , 50, Color.YELLOW, new Color (0,0,0,0)));
        if(Greenfoot.isKeyDown("space"))
        {
            Greenfoot.setWorld(new MyWorld());
        }       
    }    
    public void text() 
    {
      GreenfootImage img = getImage();
      img.clear();
      img.setColor(greenfoot.Color.WHITE);
    }
please be super specific im very new with greenfoot
danpost danpost

2019/6/18

#
Bong_Lord wrote...
im having problems with making both the world and switching the game over to that world, and the code within it has no errors but whenever all enemies are dead nothing else would happen. ive tried this in a sub world << Code Omittted >>
Where in the class did you try this?
You need to login to post a reply.