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

2020/11/25

GameOver

1
2
danpost danpost

2020/11/26

#
NewbJava wrote...
So is this the correct location.
Yes. You do still have to call the method for it to execute.
NewbJava NewbJava

2020/11/26

#
danpost wrote...
NewbJava wrote...
So is this the correct location.
Yes. You do still have to call the method for it to execute.
I have called the method but it still does not switch screens.
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

public class MyWorld extends World
{ 
     
    public MyWorld()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(600, 400, 1, false);   
        prepare();   
        
         
          
         
    } 
    public void act() 
    {  
       Switchscreen();
       if(Greenfoot.getRandomNumber(20)<1) 
       {
       addMeteor();  
       } 
       
        
    }  
    public void addMeteor() 
    { 
     addObject(new Meteors(),getWidth()-1,Greenfoot.getRandomNumber(getHeight()));
    }
    private void prepare() 
    {  
        Rocket Rocket = new Rocket(); 
        addObject(Rocket, 100,200); 
        Rocket.setLocation(70,200);  
        
    } 
    public void Switchscreen() 
 { 
     boolean noRockets = getObjects(Rocket.class).isEmpty(); 
     if (noRockets == true) 
     { 
        Greenfoot.setWorld(new Playagain()); 
 
 
   } 
}
}
danpost danpost

2020/11/26

#
Remove line 68 from the Rocket class (the "stop" line).
NewbJava NewbJava

2020/11/26

#
danpost wrote...
Remove line 68 from the Rocket class (the "stop" line).
Yes it works now thank you for your help.
You need to login to post a reply.
1
2