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

2012/4/18

If the time is on how can I go to the hiscore

1
2
martijn13039 martijn13039

2012/4/18

#
This is the code that I have but there is an red squear on game over if the time is op I need to be game over because than I go to the hiscore but what need I to change plz help
import greenfoot.*;  

public class TimeChecker extends Actor 
{    
 long initialTime; 



 public TimeChecker() 
 {         
 initialTime = System.currentTimeMillis();    
}
  public void act() 
  {         
  if(System.currentTimeMillis() > initialTime + 60000) 
  gameOver();
  Greenfoot.stop();        
}      

}  
 
davmac davmac

2012/4/18

#
What is the error message that appears at the bottom of the editor when you compile? Read it. What does it tell you?
martijn13039 martijn13039

2012/4/18

#
hey davmac in the error message stay ''cannot find symbol- method gameOver() I hope you can help me martijn
davmac davmac

2012/4/18

#
martijn, the method is telling you that there is no "gameOver()" method, which is clearly the case. You are trying to call a method which doesn't exist. You could solve the problem by writing a gameOver method - which does whatever you want it to do - or by removing the line which calls the non-existent method.
martijn13039 martijn13039

2012/4/18

#
But is this what you mean public voit gameOver() { gameOver();} what you mean
davmac davmac

2012/4/18

#
You could start with:
public void gameOver()
{

}
... yes. But you can't put "gameOver()" inside it, as it's then just calling itself. You need to put the right Java code inside the method, to do whatever it is that you want the method to do. Note that it's "void" and not "voit".
martijn13039 martijn13039

2012/4/18

#
now I have don this but there stay ilegal expresion on } this sign
import greenfoot.*;  

public class TimeChecker extends Actor 
{    
    long initialTime; 


    public TimeChecker() 
    {         
        initialTime = System.currentTimeMillis();    

  
    }  

    public void gameOver()  
    {  
        if(System.currentTimeMillis() > initialTime + 60000)
        
    }
            


    
    }
danpost danpost

2012/4/18

#
On line 17, you have an if statement, but no commands to execute if true.
martijn13039 martijn13039

2012/4/18

#
But how can I change that. I donĀ“t know what I need to change
danpost danpost

2012/4/18

#
What do you want the scenario to do after the 60 seconds is up?
martijn13039 martijn13039

2012/4/18

#
that it go to the hiscore (and you can go to hiscore if you are gameover)
danpost danpost

2012/4/18

#
You already wrote the code for GameOver()? Is it in a different class (which class is it in)?
martijn13039 martijn13039

2012/4/18

#
I have just wrote this
public void gameOver() 

    { saver.saveHighscore(counter.getValue());  
      removeObject(user);  
      board = new ScoreBoard(600, 600);  
      addObject(board, getWidth() /2, getHeight() /2);
      Greenfoot.stop();
     
    }  
danpost danpost

2012/4/18

#
And what class is it in, and what class does that class extend (Actor or World)?
martijn13039 martijn13039

2012/4/18

#
class BackGround class extend World
There are more replies on the next page.
1
2