Good day everyone
At the beginning of my game I have a startsceen where the user can select a gamemode through buttons and a small description pops up. When one Button (all are generated in one class) is clicked the others dont work anymore. This is my Button class:
It behaves like: when one codition is executed once none can be used again.
My goal is to make it so the user can switch between the gamemodes (and the desciptions) till he finds one he wants to play
private int funktion;
Description description = new Description();
/**
* Ermöglicht mehrere Buttons mit unterschiedlichen Funktionen in einer Klasse.
*/
public Button(int width, int height, String pName, int pFunktion) {
GreenfootImage image = new GreenfootImage("Button.png");
image.drawString(pName, width/2-pName.length()*3, height/2);
funktion = pFunktion;
setImage(image);
}
/**
* Überprüft ob ein Button gedrückt wurde.
*/
public void act()
{
if (funktion==1 && Greenfoot.mouseClicked(this)) {
Welt.gamemode = 1;
getWorld().addObject(description, 242, 371) ;
}
if ( funktion==2 && Greenfoot.mouseClicked(this)) {
Welt.gamemode = 2;
getWorld().addObject(description, 242, 371) ;
}
if (funktion == 3 && Greenfoot.mouseClicked(this)) {
Welt.gamemode = 3;
getWorld().addObject(description, 242,371) ;
}

