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

2022/5/10

I need help, to put a "Game over" screen or an animation that says game over in greenfoot

1
2
danpost danpost

2022/5/11

#
Roshan123 wrote...
Here it goes
public class GameOver
{
  GifImage gifImg = new GifImage("gameover.gif");
  public void act
  {
     setImage(gifImg.getCurrentImage());
  }
}
Line 1 should be:
public class GameOver extends Actor
with the following line at the top of the class:
import greenfoot.*;
As an alternative, line 1 could be written as:
public class GameOver extends greenfoot.Actor
MR.UWU MR.UWU

2022/5/11

#
OK thank you very much
Roshan123 Roshan123

2022/5/12

#
danpost wrote...
Line 1 should be:
public class GameOver extends Actor
Oh, sorry. I literally forgot to make it a subclass of Actor class
MR.UWU MR.UWU

2022/5/12

#
how do i create a start menu can someone help me
MR.UWU MR.UWU

2022/5/12

#
because I have one but it is damaged with the gameover screen
MR.UWU MR.UWU

2022/5/12

#
this is the start menu code import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Menu here. * * @author (your name) * @version (a version number or a date) */ public class Menu extends World { flecha flecha= new flecha(); private int opcion=0; /** * Constructor for objects of class Menu. * */ public Menu() { super(600, 400, 1); prepararMundo(); } private void prepararMundo() { addObject(new Play(),300,190); addObject(new Goout(),320,250); addObject(flecha,230,185); } public void act() { if (Greenfoot.isKeyDown("UP") && opcion!=0) {opcion++;} if (Greenfoot.isKeyDown("DOWN") && opcion!=1) {opcion--;} if (opcion>=2) opcion=0; if (opcion<0) opcion=1; flecha.setLocation(275,250 +(opcion*100)); if (Greenfoot.isKeyDown("SPACE") || Greenfoot.isKeyDown("ENTER")) { switch(opcion) { case 0: Greenfoot.setWorld(new MyWorld()); break; case 1: Greenfoot.stop(); break; } } } }
danpost danpost

2022/5/12

#
MR.UWU wrote...
because I have one but it is damaged with the gameover screen
What do you mean by "is damaged with the gameover screen"? Details please! Nothing seems totally wrong with the Menu class given here.
MR.UWU MR.UWU

2022/5/12

#
I mean the menu is what is wrong because when I collide with a rival it shows the game over screen fine but when I reset it in the game menu it appears together with the game over screen
Roshan123 Roshan123

2022/5/12

#
MR.UWU wrote...
I mean the menu is what is wrong because when I collide with a rival it shows the game over screen fine but when I reset it in the game menu it appears together with the game over screen
You might have used static keyword somewhere. Probably this might be the cause of it (just a guess, not sure though)
MR.UWU MR.UWU

3 days ago

#
Can someone help me how to put an animation in greenfoot for my menu please tell me
Roshan123 Roshan123

3 days ago

#
MR.UWU wrote...
Can someone help me how to put an animation in greenfoot for my menu please tell me
Before posting anything, please try to read as a third person. Would you please add some common points like, how the animation should look like and how it should work (for example, if the cursor is above the menu, it's complexion turns darker)
You need to login to post a reply.
1
2