Hey,
I want to create a class for buttons sending a signal to the current world they're spawned in.
The constructor of the button looks like this:
And the function which handles the click looks like this:
This is how the button is created:
And this is the function buttonClicked:
Or would it be better to check wether a button is pressed or not in the current world and not in the class button?
thanks for your help,
Nicotinamidadenindinukleotid
public Button(int buttonId, World world) {
id = buttonId;
currentWorld = world;
}public void click() {
currentWorld.buttonClicked(1);
}
addObject(new Button(0, this), 100, 200);
public void buttonClicked(int buttonId) {
switch(buttonId) {
case 0: //Spiel stumm schalten
addObject(new Text("*Spiel stumm*"), 1000, 200);
}
}