use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class ScreenshotAppState method initialize.
@Override
public void initialize(AppStateManager stateManager, Application app) {
if (!super.isInitialized()) {
InputManager inputManager = app.getInputManager();
inputManager.addMapping("ScreenShot", new KeyTrigger(KeyInput.KEY_SYSRQ));
inputManager.addListener(this, "ScreenShot");
List<ViewPort> vps = app.getRenderManager().getPostViews();
ViewPort last = vps.get(vps.size() - 1);
last.addProcessor(this);
if (shotName == null) {
shotName = app.getClass().getSimpleName();
}
}
super.initialize(stateManager, app);
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestCameraMotionPath method initInputs.
private void initInputs() {
inputManager.addMapping("display_hidePath", new KeyTrigger(KeyInput.KEY_P));
inputManager.addMapping("SwitchPathInterpolation", new KeyTrigger(KeyInput.KEY_I));
inputManager.addMapping("tensionUp", new KeyTrigger(KeyInput.KEY_U));
inputManager.addMapping("tensionDown", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("play_stop", new KeyTrigger(KeyInput.KEY_SPACE));
ActionListener acl = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("display_hidePath") && keyPressed) {
if (active) {
active = false;
path.disableDebugShape();
} else {
active = true;
path.enableDebugShape(assetManager, rootNode);
}
}
if (name.equals("play_stop") && keyPressed) {
if (playing) {
playing = false;
cameraMotionControl.stop();
chaser.setEnabled(true);
camNode.setEnabled(false);
} else {
playing = true;
chaser.setEnabled(false);
camNode.setEnabled(true);
cameraMotionControl.play();
}
}
if (name.equals("SwitchPathInterpolation") && keyPressed) {
if (path.getPathSplineType() == SplineType.CatmullRom) {
path.setPathSplineType(SplineType.Linear);
} else {
path.setPathSplineType(SplineType.CatmullRom);
}
}
if (name.equals("tensionUp") && keyPressed) {
path.setCurveTension(path.getCurveTension() + 0.1f);
System.err.println("Tension : " + path.getCurveTension());
}
if (name.equals("tensionDown") && keyPressed) {
path.setCurveTension(path.getCurveTension() - 0.1f);
System.err.println("Tension : " + path.getCurveTension());
}
}
};
inputManager.addListener(acl, "display_hidePath", "play_stop", "SwitchPathInterpolation", "tensionUp", "tensionDown");
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestJaime method setupInput.
public void setupInput() {
inputManager.addMapping("start", new KeyTrigger(KeyInput.KEY_PAUSE));
inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("start") && isPressed) {
if (cinematic.getPlayState() != PlayState.Playing) {
cinematic.play();
} else {
cinematic.pause();
}
}
}
}, "start");
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestMotionPath method initInputs.
private void initInputs() {
inputManager.addMapping("display_hidePath", new KeyTrigger(KeyInput.KEY_P));
inputManager.addMapping("SwitchPathInterpolation", new KeyTrigger(KeyInput.KEY_I));
inputManager.addMapping("tensionUp", new KeyTrigger(KeyInput.KEY_U));
inputManager.addMapping("tensionDown", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("play_stop", new KeyTrigger(KeyInput.KEY_SPACE));
ActionListener acl = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("display_hidePath") && keyPressed) {
if (active) {
active = false;
path.disableDebugShape();
} else {
active = true;
path.enableDebugShape(assetManager, rootNode);
}
}
if (name.equals("play_stop") && keyPressed) {
if (playing) {
playing = false;
motionControl.stop();
} else {
playing = true;
motionControl.play();
}
}
if (name.equals("SwitchPathInterpolation") && keyPressed) {
if (path.getPathSplineType() == SplineType.CatmullRom) {
path.setPathSplineType(SplineType.Linear);
} else {
path.setPathSplineType(SplineType.CatmullRom);
}
}
if (name.equals("tensionUp") && keyPressed) {
path.setCurveTension(path.getCurveTension() + 0.1f);
System.err.println("Tension : " + path.getCurveTension());
}
if (name.equals("tensionDown") && keyPressed) {
path.setCurveTension(path.getCurveTension() - 0.1f);
System.err.println("Tension : " + path.getCurveTension());
}
}
};
inputManager.addListener(acl, "display_hidePath", "play_stop", "SwitchPathInterpolation", "tensionUp", "tensionDown");
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestRagdollCharacter method setupKeys.
private void setupKeys() {
inputManager.addMapping("Rotate Left", new KeyTrigger(KeyInput.KEY_H));
inputManager.addMapping("Rotate Right", new KeyTrigger(KeyInput.KEY_K));
inputManager.addMapping("Walk Forward", new KeyTrigger(KeyInput.KEY_U));
inputManager.addMapping("Walk Backward", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("Slice", new KeyTrigger(KeyInput.KEY_SPACE), new KeyTrigger(KeyInput.KEY_RETURN));
inputManager.addListener(this, "Strafe Left", "Strafe Right");
inputManager.addListener(this, "Rotate Left", "Rotate Right");
inputManager.addListener(this, "Walk Forward", "Walk Backward");
inputManager.addListener(this, "Slice");
}
Aggregations