i am trying to understand AbstractControl and i,ve make this short example but it won’t run whats the poblem , i,ve added image
below that what i do in this example and also CodeMAIN CLASS
public class Main extends SimpleApplication implements ActionListener{
Node node1;
public static final String MAPPING_MOVE_RIGHT=“moveRight”;
public static final String MAPPING_MOVE_LEFT=“moveLeft”;
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
node1=new Node("boxNode");
Box b = new Box(.5f, 3, .5f);
Geometry geom = new Geometry("Box", b);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
geom.setMaterial(mat);
geom.setLocalTranslation(0, 1.5f, 0);
node1.addControl(new Node_1_Control());
rootNode.attachChild(node1);
inputManager.addMapping(MAPPING_MOVE_RIGHT,new KeyTrigger(KeyInput.KEY_K) );
inputManager.addMapping(MAPPING_MOVE_LEFT,new KeyTrigger(KeyInput.KEY_L) );
inputManager.addListener(this, "moveLeft","moveRight");
}
public void onAction(String name, boolean isPressed, float tpf) {
if(name.equals("moveLeft")){node1.getControl(Node_1_Control.class).moveRight=isPressed;}
else if(name.equals("moveRight")){node1.getControl(Node_1_Control.class).moveLeft=isPressed;}
};
}
CONTROL CLASS
public class Node_1_Control extends AbstractControl {
public boolean moveRight,moveLeft;
Node_1_Control() {
}
@Override
protected void controlUpdate(float tpf) {
if(moveRight){spatial.rotate(0, 0, 4*tpf);
}else if(moveLeft){spatial.rotate(0, 0, -4*tpf);
}
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
}
}