本文整理匯總了Java中com.jme3.input.KeyInput類的典型用法代碼示例。如果您正苦於以下問題:Java KeyInput類的具體用法?Java KeyInput怎麽用?Java KeyInput使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
KeyInput類屬於com.jme3.input包,在下文中一共展示了KeyInput類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initInput
import com.jme3.input.KeyInput; //導入依賴的package包/類
private void initInput(){
getInputManager().addMapping("LEFT", new KeyTrigger(KeyInput.KEY_J));
getInputManager().addMapping("RIGHT", new KeyTrigger(KeyInput.KEY_L));
getInputManager().addMapping("UP", new KeyTrigger(KeyInput.KEY_I));
getInputManager().addMapping("DOWN", new KeyTrigger(KeyInput.KEY_K));
getInputManager().addMapping("JUMP", new KeyTrigger(KeyInput.KEY_SPACE));
getInputManager().addListener((ActionListener) (name, isPressed, tpf) -> {
Vector2f movement = new Vector2f();
if(isPressed){
switch (name) {
case "LEFT": movement.setX(-1); break;
case "RIGHT": movement.setX(+1); break;
case "UP": movement.setY(-1); break;
case "DOWN": movement.setY(+1); break;
}
}
entityData.setComponent(character, new PhysicsCharacterMovement(movement));
}, "LEFT", "RIGHT", "UP", "DOWN");
getInputManager().addListener((ActionListener) (name, isPressed, tpf) ->
entityData.setComponent(character, new PhysicsCharacterState(isPressed, false)
), "JUMP");
}
示例2: initInput
import com.jme3.input.KeyInput; //導入依賴的package包/類
private void initInput(){
getInputManager().addMapping("LEFT", new KeyTrigger(KeyInput.KEY_J));
getInputManager().addMapping("RIGHT", new KeyTrigger(KeyInput.KEY_L));
getInputManager().addMapping("UP", new KeyTrigger(KeyInput.KEY_I));
getInputManager().addMapping("DOWN", new KeyTrigger(KeyInput.KEY_K));
getInputManager().addMapping("JUMP", new KeyTrigger(KeyInput.KEY_SPACE));
getInputManager().addListener((ActionListener) (name, isPressed, tpf) -> {
Vector2f movement = new Vector2f();
if(isPressed){
switch (name) {
case "LEFT": movement.setX(-1); break;
case "RIGHT": movement.setX(+1); break;
case "UP": movement.setY(-1); break;
case "DOWN": movement.setY(+1); break;
}
movement.multLocal(CHARACTER_MASS*MOVE_ACCELERATION);
}
entityData.setComponent(character, new MoveForce(movement));
}, "LEFT", "RIGHT", "UP", "DOWN");
getInputManager().addListener((ActionListener) (name, isPressed, tpf) -> {
if(isPressed) entityData.setComponent(character, new JumpState(true));
}, "JUMP");
}
示例3: initialize
import com.jme3.input.KeyInput; //導入依賴的package包/類
@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
this.app = app;
attachAction(
"wireframe-mode",
new KeyTrigger(KeyInput.KEY_TAB),
this::toggleWireframeMode);
attachAction(
"mouse-lock",
new KeyTrigger(KeyInput.KEY_F1),
this::toggleMouseLock);
attachAction(
"show-axis",
new KeyTrigger(KeyInput.KEY_F2),
this::toggleAxis);
attachAction(
"show-grids",
new KeyTrigger(KeyInput.KEY_F3),
this::toggleGrids);
}
示例4: getCurrentModifiers
import com.jme3.input.KeyInput; //導入依賴的package包/類
private int getCurrentModifiers( int swingBtton ) {
int modifiers = 0;
if ( isKeyDown( KeyInput.KEY_LMENU ) ) {
modifiers |= InputEvent.ALT_DOWN_MASK;
modifiers |= InputEvent.ALT_MASK;
}
if ( isKeyDown( KeyInput.KEY_RMENU ) ) {
modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
modifiers |= InputEvent.ALT_GRAPH_MASK;
}
if ( isKeyDown( KeyInput.KEY_LCONTROL ) || isKeyDown( KeyInput.KEY_RCONTROL ) ) {
modifiers |= InputEvent.CTRL_DOWN_MASK;
modifiers |= InputEvent.CTRL_MASK;
}
if ( isKeyDown( KeyInput.KEY_LSHIFT ) || isKeyDown( KeyInput.KEY_RSHIFT ) ) {
modifiers |= InputEvent.SHIFT_DOWN_MASK;
modifiers |= InputEvent.SHIFT_MASK;
}
return modifiers | getButtonMask( swingBtton );
}
示例5: setupKeys
import com.jme3.input.KeyInput; //導入依賴的package包/類
private void setupKeys() {
flyCam.setMoveSpeed(50);
inputManager.addMapping("wireframe", new KeyTrigger(KeyInput.KEY_T));
inputManager.addListener(actionListener, "wireframe");
inputManager.addMapping("Lefts", new KeyTrigger(KeyInput.KEY_H));
inputManager.addMapping("Rights", new KeyTrigger(KeyInput.KEY_K));
inputManager.addMapping("Ups", new KeyTrigger(KeyInput.KEY_U));
inputManager.addMapping("Downs", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("Forwards", new KeyTrigger(KeyInput.KEY_Y));
inputManager.addMapping("Backs", new KeyTrigger(KeyInput.KEY_I));
inputManager.addListener(actionListener, "Lefts");
inputManager.addListener(actionListener, "Rights");
inputManager.addListener(actionListener, "Ups");
inputManager.addListener(actionListener, "Downs");
inputManager.addListener(actionListener, "Forwards");
inputManager.addListener(actionListener, "Backs");
inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, "shoot");
inputManager.addMapping("cameraDown", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
inputManager.addListener(actionListener, "cameraDown");
}
示例6: simpleInitApp
import com.jme3.input.KeyInput; //導入依賴的package包/類
@Override
public void simpleInitApp() {
// Initializes the appstates
stateManager.attachAll(new VisualAppState(),
new GameplayAppState(),
// FIXME: This feature is still not totally funcional
// and is causing weird behaviour. Don't uncomment
/*new BillboardAppState(),*/
new EntityDataState());
viewPort.setBackgroundColor(ColorRGBA.Cyan);
inputManager.addMapping("+", new KeyTrigger(KeyInput.KEY_I));
inputManager.addMapping("-", new KeyTrigger(KeyInput.KEY_O));
inputManager.addListener(analogListener, "+", "-");
}
示例7: simpleInitApp
import com.jme3.input.KeyInput; //導入依賴的package包/類
public void simpleInitApp() {
Geometry teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
DirectionalLight dl = new DirectionalLight();
dl.setColor(ColorRGBA.White);
dl.setDirection(Vector3f.UNIT_XYZ.negate());
rootNode.addLight(dl);
rootNode.attachChild(teaGeom);
// Setup first view
cam.setParallelProjection(true);
float aspect = (float) cam.getWidth() / cam.getHeight();
cam.setFrustum(-1000, 1000, -aspect * frustumSize, aspect * frustumSize, frustumSize, -frustumSize);
inputManager.addListener(this, "Size+", "Size-");
inputManager.addMapping("Size+", new KeyTrigger(KeyInput.KEY_W));
inputManager.addMapping("Size-", new KeyTrigger(KeyInput.KEY_S));
}
示例8: initInputs
import com.jme3.input.KeyInput; //導入依賴的package包/類
private void initInputs() {
inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
ActionListener acl = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("toggle") && keyPressed) {
if(active){
active=false;
viewPort.removeProcessor(fpp);
}else{
active=true;
viewPort.addProcessor(fpp);
}
}
}
};
inputManager.addListener(acl, "toggle");
}
示例9: simpleInitApp
import com.jme3.input.KeyInput; //導入依賴的package包/類
@Override
public void simpleInitApp() {
cam.setLocation(new Vector3f(3, 3, 3));
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
//setup main scene
Geometry quad = new Geometry("box", new Box(Vector3f.ZERO, 1,1,1));
Texture offTex = setupOffscreenView();
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", offTex);
quad.setMaterial(mat);
rootNode.attachChild(quad);
inputManager.addMapping(TOGGLE_UPDATE, new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addListener(this, TOGGLE_UPDATE);
}
示例10: setupKeys
import com.jme3.input.KeyInput; //導入依賴的package包/類
private void setupKeys() {
inputManager.addMapping("wireframe", new KeyTrigger(KeyInput.KEY_T));
inputManager.addListener(this, "wireframe");
inputManager.addMapping("CharLeft", new KeyTrigger(KeyInput.KEY_A));
inputManager.addMapping("CharRight", new KeyTrigger(KeyInput.KEY_D));
inputManager.addMapping("CharUp", new KeyTrigger(KeyInput.KEY_W));
inputManager.addMapping("CharDown", new KeyTrigger(KeyInput.KEY_S));
inputManager.addMapping("CharSpace", new KeyTrigger(KeyInput.KEY_RETURN));
inputManager.addMapping("CharShoot", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addListener(this, "CharLeft");
inputManager.addListener(this, "CharRight");
inputManager.addListener(this, "CharUp");
inputManager.addListener(this, "CharDown");
inputManager.addListener(this, "CharSpace");
inputManager.addListener(this, "CharShoot");
}
示例11: setupKeys
import com.jme3.input.KeyInput; //導入依賴的package包/類
private void setupKeys() {
inputManager.addMapping("Lefts", new KeyTrigger(KeyInput.KEY_H));
inputManager.addMapping("Rights", new KeyTrigger(KeyInput.KEY_K));
inputManager.addMapping("Ups", new KeyTrigger(KeyInput.KEY_U));
inputManager.addMapping("Downs", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("Space", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(this, "shoot");
inputManager.addListener(this, "Lefts");
inputManager.addListener(this, "Rights");
inputManager.addListener(this, "Ups");
inputManager.addListener(this, "Downs");
inputManager.addListener(this, "Space");
inputManager.addMapping("gc", new KeyTrigger(KeyInput.KEY_X));
inputManager.addListener(this, "gc");
}
示例12: initialize
import com.jme3.input.KeyInput; //導入依賴的package包/類
@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
this.app = (SimpleApplication)app;
this.ed = this.app.getStateManager().getState(EntityDataState.class).getEntityData();
this.entities = this.ed.getEntities(Transform.class, Billboard.class);
this.inputManager = this.app.getInputManager();
this.inputManager.addMapping("Update", new KeyTrigger(KeyInput.KEY_W),
new KeyTrigger(KeyInput.KEY_S),
new KeyTrigger(KeyInput.KEY_A),
new KeyTrigger(KeyInput.KEY_D),
new KeyTrigger(KeyInput.KEY_Q),
new KeyTrigger(KeyInput.KEY_Z));
this.inputManager.addListener(analogListener, "Update");
}
示例13: initInput
import com.jme3.input.KeyInput; //導入依賴的package包/類
protected void initInput() {
flyCam.setMoveSpeed(3);
//init input
inputManager.addMapping("use_water", new KeyTrigger(KeyInput.KEY_O));
inputManager.addListener(this, "use_water");
inputManager.addMapping("lightup", new KeyTrigger(KeyInput.KEY_T));
inputManager.addListener(this, "lightup");
inputManager.addMapping("lightdown", new KeyTrigger(KeyInput.KEY_G));
inputManager.addListener(this, "lightdown");
inputManager.addMapping("lightleft", new KeyTrigger(KeyInput.KEY_H));
inputManager.addListener(this, "lightleft");
inputManager.addMapping("lightright", new KeyTrigger(KeyInput.KEY_K));
inputManager.addListener(this, "lightright");
inputManager.addMapping("lightforward", new KeyTrigger(KeyInput.KEY_U));
inputManager.addListener(this, "lightforward");
inputManager.addMapping("lightback", new KeyTrigger(KeyInput.KEY_J));
inputManager.addListener(this, "lightback");
}
示例14: simpleInitApp
import com.jme3.input.KeyInput; //導入依賴的package包/類
@Override
public void simpleInitApp() {
inputManager.addMapping("WordWrap", new KeyTrigger(KeyInput.KEY_TAB));
inputManager.addListener(keyListener, "WordWrap");
inputManager.addRawInputListener(textListener);
BitmapFont fnt = assetManager.loadFont("Interface/Fonts/Default.fnt");
txt = new BitmapText(fnt, false);
txt.setBox(new Rectangle(0, 0, settings.getWidth(), settings.getHeight()));
txt.setSize(fnt.getPreferredSize() * 2f);
txt.setText(txtB);
txt.setLocalTranslation(0, txt.getHeight(), 0);
guiNode.attachChild(txt);
txt2 = new BitmapText(fnt, false);
txt2.setSize(fnt.getPreferredSize() * 1.2f);
txt2.setText("Text without restriction. \nText without restriction. Text without restriction. Text without restriction");
txt2.setLocalTranslation(0, txt2.getHeight(), 0);
guiNode.attachChild(txt2);
txt3 = new BitmapText(fnt, false);
txt3.setBox(new Rectangle(0, 0, settings.getWidth(), 0));
txt3.setText("Press Tab to toggle word-wrap. type text and enter to input text");
txt3.setLocalTranslation(0, settings.getHeight()/2, 0);
guiNode.attachChild(txt3);
}
示例15: onKeyEventQueued
import com.jme3.input.KeyInput; //導入依賴的package包/類
private void onKeyEventQueued(KeyInputEvent evt, NiftyInputConsumer nic) {
int code = evt.getKeyCode();
if (code == KeyInput.KEY_LSHIFT || code == KeyInput.KEY_RSHIFT) {
shiftDown = evt.isPressed();
} else if (code == KeyInput.KEY_LCONTROL || code == KeyInput.KEY_RCONTROL) {
ctrlDown = evt.isPressed();
}
KeyboardInputEvent keyEvt = new KeyboardInputEvent(code,
evt.getKeyChar(),
evt.isPressed(),
shiftDown,
ctrlDown);
if (nic.processKeyboardEvent(keyEvt)){
evt.setConsumed();
}
}