Good afternoon,
I’m a Information & Multimedia Technologies student with beginner-intermediate Java knowledge. I just started learning the JMonkeyEngine.
While I was following the Tutorial 5 (Hello Input), I encountered the following errors:
HelloInput is not abstract and does not override abstract method simpleInitApp() in SimpleApplication
public class HelloInput
method does not override or implement a method from a supertype
@Override
I double checked the tutorial code with mine, the only variation is some variable names.
package jme3test.helloworld;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
import com.jme3.input.KeyInput;
import com.jme3.input.MouseInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.AnalogListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.input.controls.MouseButtonTrigger;
public class HelloInput
extends SimpleApplication
{
public static void main (String[] argv)
{
HelloInput app = new HelloInput();
app.start();
}
protected Geometry jugador;
Boolean isRunning=true;
@Override
public void SimpleInitApp()
{
Box caja = new Box (1,1,1);
jugador = new Geometry ("Jugador", caja);
Material material = new Material(assetManager,
"Common/MatDefs/Misc/Unshaded.j3md");
material.setColor("Color", ColorRGBA.Blue);
jugador.setMaterial(material);
rootNode.attachChild(jugador);
initKeys();
}
private void initKeys()
{
inputManager.addMapping("Pause", new KeyTrigger(KeyInput.KEY_P));
inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_K));
inputManager.addMapping("Rotate", new KeyTrigger(KeyInput.KEY_SPACE),
new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, "Pause");
inputManager.addListener(analogListener, "Left", "Right", "Rotate");
}
private ActionListener actionListener = new ActionListener()
{
public void onAction (String nombre, boolean keyPressed, float tpf)
{
if (nombre.equals("Pause") && !keyPressed)
{
isRunning = !isRunning;
}
}
};
private AnalogListener analogListener = new AnalogListener()
{
public void onAnalog(String nombre, float valor, float tpf)
{
if (isRunning)
{
if (nombre.equals("Rotate"))
{
jugador.rotate(0, valor*speed, 0);
}
if(nombre.equals("Right"))
{
Vector3f vector = jugador.getLocalTranslation();
jugador.setLocalTranslation(vector.x + valor*speed, vector.y, vector.z);
}
if (nombre.equals("Left"))
{
Vector3f vector = jugador.getLocalTranslation();
jugador.setLocalTranslation(vector.x - valor*speed, vector.y, vector.z);
}
}
else
{
System.out.println("Press P to unpause.");
}
}
};
}
Would you please point me out what I should fix?
Thank you.