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

2016/11/12

Hello... I need statement regarding pop-up window.

riyazahamed887 riyazahamed887

2016/11/12

#
In my game, when the car hits a barrier or any obstacle, it has to show game-over/wins... I need help regarding this issue. I have tried various set of statements, but none of them worked.. And I need this statement to be placed inside the Intersect statement loop..
danpost danpost

2016/11/12

#
riyazahamed887 wrote...
In my game, when the car hits a barrier or any obstacle, it has to show game-over/wins... I need help regarding this issue. I have tried various set of statements, but none of them worked.. And I need this statement to be placed inside the Intersect statement loop..
The basics should be something like this:
if ( ! getIntersectingObjects(Obstacle.class).isEmpty() && getWorld().getObjects(GameOver.class).isEmpty()) // you may be using something a bit different
{
    World w = getWorld();
    int wWide = w.getWidth();
    int wHigh = w.getHeight();
    w.addObject(new GameOver(), wWide/2, wHigh/2);
    // any other game over actions
}
You need to login to post a reply.