I want to add my end score into my game over screen and winnerscreen...I've tried a few things with system out println
but it didn't work though
public class GAMEOVERSCHERM extends World
{
/**
* Constructor for objects of class GAMEOVERSCHERM.
*
*/
public GAMEOVERSCHERM()
{
super(400,300,1);
Greenfoot.playSound("fail-trombone-03.mp3");
addObject(new TRYAGAIN(), 200,80);
endScore();
}
public void endScore()
{
Vracht vracht = new Vracht();
Counterve counterve = new Counterve();
drawString();
}
}// previously declared and used instance field
int score;
// for game over world
int wide = getWorld().getWidth() * getWorld().getCellSize();
int high = getWorld().getHeight() * getWorld().getCellSize();
World goWorld = new World(wide, high, 1){};
GreenfootImage bg = goWorld.getBackground();
bg.setColor(java.awt.Color.lightGray);
bg.fill();
String text = "Game Over\n\nScore: "+score;
GreenfootImage textImage = new GreenfootImage(text, 84, java.awt.Color.orange, null);
bg.drawImage(textImage, (bg.getWidth()-textImage.getWidth())/2, (bg.getHeight()-textImage.getHeight())/2);
Greenfoot.setWorld(goWorld);
Greenfoot.stop();Actor textActor = new Actor(){};
textActor.setImage(textImage);
goWorld.addObject(textActor, wide/2, high/2);