In Objective C you have a function blocks.
You can save blocks of code in a variable and pass them as parameters.
[objects enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
// Enumerating all the objects of an array
}];
In my game I have a MenuScene with MenuSceneItems.
In this case I would want to pass the code they should execute if they have been clicked.
This would eliminate the need of a switch statement.
Is there a way to to is there a way to do this or something similar in Java?
In Java you can’t have anonymous function blocks you need to use an anonymous class: