I want my gameover world to display when 8 points is reached by one player. right now I have the code for the delay in which the gameover screen should display but do not understand why when I run my game the delay happens after 8 points is reached but the image does not display. this is my code for my world class (PongWorld) that I want to put the gameover code into
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class PongWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class PongWorld extends World
{
private Paddle paddle;
public Paddle paddle1;
public Paddle paddle2;
public Counter score1;
public Counter score2;
public Gameover Gameover;
/**
* Constructor for objects of class PongWorld.
*
*/
public PongWorld()
{
// Create a new world with 20x20 cells with a cell size of 10x10 pixels.
super(700, 500, 1);
score1=new Counter();
score2= new Counter();
addObject (score1, 50, 35);
addObject(score2,50,465);
paddle1 = new Paddle();
addObject ( paddle1, getWidth() / 2, getHeight() - 40);
paddle2 = new Paddle("a","s");
addObject ( paddle2, getWidth() / 2, getHeight() - 450);
addObject(new Ball(), 350, 250);
GreenfootImage bg = new GreenfootImage("pink.jpg");
bg.scale(getWidth(), getHeight());
setBackground(bg);
}
public void scoreTop()
{
score1.add(1);
}
public void scoreBottom()
{
score2.add(1);
}
public void act()
{if (score1.getValue()==8)
{
Greenfoot.setWorld(new Gameover());
Greenfoot.delay (120);
}
if (score2.getValue()==8)
{
Greenfoot.setWorld(new Gameover());
Greenfoot.delay (120);
}
}
}
