With the commented-out code uncommented, you’re trying to declare a constructor directly within a method. You can’t do that in Java.
// You can't do this
buttonPlay.addListener(new ClickListener(){ // 1
public void clicked(InputEvent event, float x, float y) { // 2
public GameScreen(Create create) { // 3
this.create = create; // 3
} // 3
}
});
-
Instantiating an anonymous class. This is fine.
-
Implementing a method of that anonymous class (you want to add an
@Override
there). Also fine. -
Declaring a constructor directly within another method. You can’t do that.
1
solved Got a very strange syntax error in java