當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyTrigger類代碼示例

本文整理匯總了Java中com.jme3.input.controls.KeyTrigger的典型用法代碼示例。如果您正苦於以下問題:Java KeyTrigger類的具體用法?Java KeyTrigger怎麽用?Java KeyTrigger使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


KeyTrigger類屬於com.jme3.input.controls包,在下文中一共展示了KeyTrigger類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initInput

import com.jme3.input.controls.KeyTrigger; //導入依賴的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");
}
 
開發者ID:jvpichowski,項目名稱:ZayES-Bullet,代碼行數:23,代碼來源:DynamicCharacterExample.java

示例2: initInput

import com.jme3.input.controls.KeyTrigger; //導入依賴的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");
}
 
開發者ID:jvpichowski,項目名稱:ZayES-Bullet,代碼行數:24,代碼來源:CustomCharacterExample.java

示例3: initialize

import com.jme3.input.controls.KeyTrigger; //導入依賴的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);
}
 
開發者ID:quadracoatl,項目名稱:quadracoatl,代碼行數:27,代碼來源:GameInputState.java

示例4: initInputs

import com.jme3.input.controls.KeyTrigger; //導入依賴的package包/類
private void initInputs() {
    inputManager.addMapping("togglePause", new KeyTrigger(keyInput.KEY_RETURN));
    ActionListener acl = new ActionListener() {
        public void onAction(String name, boolean keyPressed, float tpf) {
            if (name.equals("togglePause") && keyPressed) {
                if (cinematic.getPlayState() == PlayState.Playing) {
                    cinematic.pause();
                } else {
                    cinematic.play();
                }
            }

        }
    };
    inputManager.addListener(acl, "togglePause");
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:17,代碼來源:TestCinematic.java

示例5: setupKeys

import com.jme3.input.controls.KeyTrigger; //導入依賴的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");
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:22,代碼來源:TerrainTestCollision.java

示例6: simpleInitApp

import com.jme3.input.controls.KeyTrigger; //導入依賴的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));
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:20,代碼來源:TestParallelProjection.java

示例7: initInputs

import com.jme3.input.controls.KeyTrigger; //導入依賴的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");

}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:22,代碼來源:TestPosterization.java

示例8: simpleInitApp

import com.jme3.input.controls.KeyTrigger; //導入依賴的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);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:18,代碼來源:TestRenderToTexture.java

示例9: setupKeys

import com.jme3.input.controls.KeyTrigger; //導入依賴的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");
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:17,代碼來源:TestWalkingChar.java

示例10: setupKeys

import com.jme3.input.controls.KeyTrigger; //導入依賴的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");
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:17,代碼來源:TestPhysicsCharacter.java

示例11: initInput

import com.jme3.input.controls.KeyTrigger; //導入依賴的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");
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:19,代碼來源:TestSimpleWater.java

示例12: simpleInitApp

import com.jme3.input.controls.KeyTrigger; //導入依賴的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);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:27,代碼來源:TestBitmapFont.java

示例13: initKeys

import com.jme3.input.controls.KeyTrigger; //導入依賴的package包/類
public void initKeys(InputManager inputManager) {
    inputManager.addMapping(name + "LeftClick", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addMapping(name + "RightClick", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
    inputManager.addMapping(name + "MouseMove",
            new MouseAxisTrigger(MouseInput.AXIS_X, true),
            new MouseAxisTrigger(MouseInput.AXIS_X, false),
            new MouseAxisTrigger(MouseInput.AXIS_Y, true),
            new MouseAxisTrigger(MouseInput.AXIS_Y, false));
    inputManager.addMapping(name + "PlaneRotate", new KeyTrigger(KeyInput.KEY_SLASH));
    inputManager.addMapping(name + "PlaneRotate90", new KeyTrigger(KeyInput.KEY_LCONTROL));

    inputManager.addListener(this, "shiftKey");

    inputManager.addListener(this, name + "LeftClick");
    inputManager.addListener(this, name + "RightClick");
    inputManager.addListener(this, name + "MouseMove");
    inputManager.addListener(this, name + "PlaneRotate");
    inputManager.addListener(this, name + "PlaneRotate90");
}
 
開發者ID:dwhuang,項目名稱:SMILE,代碼行數:20,代碼來源:Demonstrator.java

示例14: initKeys

import com.jme3.input.controls.KeyTrigger; //導入依賴的package包/類
private void initKeys() {
    inputManager.addMapping("shiftKey", new KeyTrigger(KeyInput.KEY_LSHIFT));
    inputManager.addMapping("shiftKey", new KeyTrigger(KeyInput.KEY_RSHIFT));
    inputManager.addMapping("escapeKey", new KeyTrigger(KeyInput.KEY_ESCAPE));
    inputManager.addMapping("spaceKey", new KeyTrigger(KeyInput.KEY_SPACE));
    
    inputManager.addListener(this, "shiftKey");
    inputManager.addListener(this, "escapeKey");
    inputManager.addListener(this, "spaceKey");
    
    table.initKeys(inputManager);
    robot.initKeys(inputManager);
    demonstrator.initKeys(inputManager);

    if (flyGripper) {
        inputManager.addListener(gripper, "gripperOpen");
        inputManager.addListener(gripper, "gripperClose");
    }
}
 
開發者ID:dwhuang,項目名稱:SMILE,代碼行數:20,代碼來源:MainApp.java

示例15: keyMapping

import com.jme3.input.controls.KeyTrigger; //導入依賴的package包/類
public void keyMapping() {
	inputManager.addMapping("buttonLeft", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
	inputManager.addMapping("buttonRight", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
	inputManager.addMapping("1", new KeyTrigger(KeyInput.KEY_1));
	inputManager.addMapping("2", new KeyTrigger(KeyInput.KEY_2));
	inputManager.addMapping("3", new KeyTrigger(KeyInput.KEY_3));
	inputManager.addMapping("4", new KeyTrigger(KeyInput.KEY_4));
	inputManager.addMapping("5", new KeyTrigger(KeyInput.KEY_5));
	inputManager.addMapping("6", new KeyTrigger(KeyInput.KEY_6));
	inputManager.addMapping("w", new KeyTrigger(KeyInput.KEY_W));
	inputManager.addMapping("s", new KeyTrigger(KeyInput.KEY_S));
	inputManager.addMapping("a", new KeyTrigger(KeyInput.KEY_A));
	inputManager.addMapping("d", new KeyTrigger(KeyInput.KEY_D));
	inputManager.addMapping("space", new KeyTrigger(KeyInput.KEY_SPACE));
	inputManager.addListener(this, "1", "2", "3", "4", "5", "6", "w", "s",
			"a", "d", "space", "buttonLeft", "buttonRight");
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:18,代碼來源:TestRole.java


注:本文中的com.jme3.input.controls.KeyTrigger類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。