I've got all the tutorials up to beginner #5 translated and working, but I don't know Java well enough to know how to port the lines:
private ActionListener actionListener = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("Pause") && !keyPressed) {
isRunning = !isRunning;
}
}
};
private AnalogListener analogListener = new AnalogListener() {
public void onAnalog(String name, float value, float tpf) {
...
}
}
How might this work?
As described in Calling Java from JRuby, you can use closure conversion, where blocks can be used to define a Java interface behaviour. Something like the following should work:
l = lambda { |name, pressed, tpf| running = !running if name == 'Pause' && !pressed }
input_managers.add_listener(l, ['Left', 'Right', 'Rotate'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With