InputAction as Interface, not abstract class


is there a good reason why com.jme.input.action.InputAction is an abstract class and not an interface?

It sucks, because I don't want to derive from that class



As one would create a new class for each action either way it should not be an actual drawback to keep it as a class. The only thing that makes a class instead of an interface necessary is the speed attribute. We could extract an interface for performAction, though… why do you want it to be an interface?

I use the scripting language E on top of Java - see

With this language, you can create objects that conform to Java interfaces, which is very cool.

This code defines a valid implementation of com.jme.input.MouseInputListener:

def mousePicker {
        to onButton(button, pressed, x , y ) :void{   
      println("Mouse is pressed: "+pressed)   
        match[verb, args] {
       #catches all other function calls

So this way I can integrate my scripting environment with JME really easy.
The problem is that I can't subclass java classes in E. So to use E in an InputAction, I have to make an InputAction subclass and store a function reference to an E object in it. I have to write an adapter class, which would not be necessary if an interface was used

All this is not tragic, but coding for interfaces is just good programming practice. So it would be nice if you could change this at some point, but I won't lose any sleep if it doesn't happen.

btw I currently combine E and jme to create a network distributed scene graph. I use E because it is security focused, and I want to explore ways to make multi user interaction more secure. I am happy that I chose JME as a scene graph tool, because it does not get in the way much and is a very clean code base. Keep up the good work!

Interesting! As it's not much work for me and I also remember other people that would have liked an interface here, I extracted InputActionInterface.

Have fun :slight_smile:

(The name is not the optimum, having the InputAction renamed to InputActionAdapter and name the interface InputAction would have been better naming, but I prefered to keep it backward compatible to allow people keeping their code like it was.)

Thank you for the quick reaction!

But I think you should remove the @override line in file SimplePhysicsgame , I get a compile error now

true (I did not commit physics) - fixed