当前位置: 首页>>代码示例>>Java>>正文


Java InputManager.addListener方法代码示例

本文整理汇总了Java中com.jme3.input.InputManager.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java InputManager.addListener方法的具体用法?Java InputManager.addListener怎么用?Java InputManager.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jme3.input.InputManager的用法示例。


在下文中一共展示了InputManager.addListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initKeys

import com.jme3.input.InputManager; //导入方法依赖的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

示例2: registerWithInput

import com.jme3.input.InputManager; //导入方法依赖的package包/类
/**
 * Registers inputs with the input manager
 * @param inputManager
 */
public final void registerWithInput(InputManager inputManager) {

    String[] inputs = {EDIT_CAMERA_TOGGLEROTATE,
        EDIT_CAMERA_DOWN,
        EDIT_CAMERA_UP,
        EDIT_CAMERA_MOVELEFT,
        EDIT_CAMERA_MOVERIGHT,
        EDIT_CAMERA_ZOOMIN,
        EDIT_CAMERA_ZOOMOUT};

    this.inputManager = inputManager;
    inputManager.addMapping(EDIT_CAMERA_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
    inputManager.addMapping(EDIT_CAMERA_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
    
    inputManager.addMapping(EDIT_CAMERA_ZOOMIN, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
    inputManager.addMapping(EDIT_CAMERA_ZOOMOUT, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
    
    inputManager.addMapping(EDIT_CAMERA_MOVELEFT, new MouseAxisTrigger(MouseInput.AXIS_X, true));
    inputManager.addMapping(EDIT_CAMERA_MOVERIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, false));
    
    inputManager.addMapping(EDIT_CAMERA_TOGGLEROTATE, new MouseButtonTrigger(MouseInput.BUTTON_MIDDLE));

    inputManager.addListener(this, inputs);
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:29,代码来源:BestEditCamera.java

示例3: initControls

import com.jme3.input.InputManager; //导入方法依赖的package包/类
public void initControls(InputManager inputManager) {
    inputManager.deleteMapping(SimpleApplication.INPUT_MAPPING_EXIT);

    inputManager.addMapping("open_menu", new KeyTrigger(KeyInput.KEY_ESCAPE));
    inputManager.addMapping("view_atom", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(new ActionListener() {
        @Override
        public void onAction(String name, boolean isPressed, float tpf) {
            if ("open_menu".equals(name) && isPressed) {
                NiftyAppState s = stateManager.getState(NiftyAppState.class);
                if ("menu".equals(s.nifty.getCurrentScreen().getScreenId())) {
                    s.exitMenu();
                } else {
                    s.openMenu();
                }
            } else if ("view_atom".equals(name) && isPressed) {
                triggerViewAtom();
            }
        }
    }, "open_menu", "view_atom");
}
 
开发者ID:matthewseal,项目名称:MoleculeViewer,代码行数:22,代码来源:MVAppState.java

示例4: registerWithInput

import com.jme3.input.InputManager; //导入方法依赖的package包/类
public void registerWithInput(InputManager inputManager) {
    this.inputManager = inputManager;
 
    String[] mappings = new String[] { "+SIDE", "+FWD", "+ROTATE", "+TILT", "+DISTANCE",
            "-SIDE", "-FWD", "-ROTATE", "-TILT", "-DISTANCE", };
 
    inputManager.addMapping("-SIDE", new KeyTrigger(KeyInput.KEY_A));
    inputManager.addMapping("+SIDE", new KeyTrigger(KeyInput.KEY_D));
    inputManager.addMapping("+FWD", new KeyTrigger(KeyInput.KEY_S));
    inputManager.addMapping("-FWD", new KeyTrigger(KeyInput.KEY_W));
    inputManager.addMapping("+ROTATE", new KeyTrigger(KeyInput.KEY_Q));
    inputManager.addMapping("-ROTATE", new KeyTrigger(KeyInput.KEY_E));
    inputManager.addMapping("+TILT", new KeyTrigger(KeyInput.KEY_R));
    inputManager.addMapping("-TILT", new KeyTrigger(KeyInput.KEY_F));
    inputManager.addMapping("-DISTANCE", new KeyTrigger(KeyInput.KEY_Z));
    inputManager.addMapping("+DISTANCE", new KeyTrigger(KeyInput.KEY_X));
 
    inputManager.addListener(this, mappings);
    inputManager.setCursorVisible(true);
}
 
开发者ID:mifth,项目名称:JME-Simple-Examples,代码行数:21,代码来源:RtsCameraControl.java

示例5: setupKeys

import com.jme3.input.InputManager; //导入方法依赖的package包/类
private void setupKeys(InputManager inputManager){
 
   //Set up keys and listener to read it
    String[] mappings = new String[]{
        "MoveShip",
        "FireBullets",
        "FireRocket",
        "LockMouse",
        "SelectAim"
    };
    
    InputManager input = asm.getInputManager();
    
    input.addMapping("LockMouse", new KeyTrigger(KeyInput.KEY_SPACE));
    input.addMapping("SelectAim", new KeyTrigger(KeyInput.KEY_E));
    input.addMapping("MoveShip", new KeyTrigger(KeyInput.KEY_W));
    input.addMapping("FireBullets", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    input.addListener(anl, mappings);
    input.addListener(acl, mappings);
}
 
开发者ID:mifth,项目名称:JME-Simple-Examples,代码行数:21,代码来源:PlayerMappings.java

示例6: setupKeys

import com.jme3.input.InputManager; //导入方法依赖的package包/类
private void setupKeys() {
        InputManager inputManager = app.getInputManager();

        inputManager.addMapping("Rotate Left",
                new KeyTrigger(KeyInput.KEY_A),
                new KeyTrigger(KeyInput.KEY_LEFT));
        inputManager.addMapping("Rotate Right",
                new KeyTrigger(KeyInput.KEY_D),
                new KeyTrigger(KeyInput.KEY_RIGHT));
        inputManager.addMapping("Walk Forward",
                new KeyTrigger(KeyInput.KEY_W),
                new KeyTrigger(KeyInput.KEY_UP));
        inputManager.addMapping("Walk Backward",
                new KeyTrigger(KeyInput.KEY_S),
                new KeyTrigger(KeyInput.KEY_DOWN));
        inputManager.addMapping("Jump",
                new KeyTrigger(KeyInput.KEY_SPACE));

//        inputManager.addListener(this, "Strafe Left", "Strafe Right");
        inputManager.addListener(this, "Rotate Left", "Rotate Right");
        inputManager.addListener(this, "Walk Forward", "Walk Backward");
        inputManager.addListener(this, "Jump");

        inputManager = null;
    }
 
开发者ID:mifth,项目名称:JME-Simple-Examples,代码行数:26,代码来源:CharacterController.java

示例7: initialize

import com.jme3.input.InputManager; //导入方法依赖的package包/类
/**
 * Initializes the tool.
 *
 * @param manager the AssetManager to load objects and materials from.
 * @param inputManager can be used to register keypresses that can be used
 * with this tool.
 */
public void initialize(AssetManager manager, InputManager inputManager) {
    ObjectType objectType = GlobalObjects.getInstance().getObjectsTypeCategory().getObjectType("Terrain", "Brush");
    defaultBrush = (TerrainBrush)objectType.create(manager, "defaultbrush");
    defaultBrush.setLayerName("terrain");
    
    brushShape = new Cylinder(2, 12, defaultBrush.getRadius(), 1.0f);
    brushGizmo = new Geometry("terrainBrush", brushShape);
    Quaternion q = new Quaternion();
    q.fromAngles(FastMath.HALF_PI, 0, 0);
    brushGizmo.setLocalRotation(q);
    brushGizmo.setMaterial(manager.loadMaterial("Materials/BrushGizmoMaterial.j3m"));

    inputManager.addListener(shiftListener, new String[]{"DOBRUSH"});
    
    GlobalObjects.getInstance().registerListener(this);
    
}
 
开发者ID:samynk,项目名称:DArtE,代码行数:25,代码来源:BrushTool.java

示例8: registerInputs

import com.jme3.input.InputManager; //导入方法依赖的package包/类
@Override
public void registerInputs(InputManager inputManager){
	inputManager.addMapping(ROTATE_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
	inputManager.addMapping(ROTATE_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
	inputManager.addMapping(ROTATE_LEFT, new MouseAxisTrigger(MouseInput.AXIS_X, true));
	inputManager.addMapping(ROTATE_RIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, false));

	inputManager.addMapping(STRAFE_LEFT, new KeyTrigger(KeyInput.KEY_Q),
			new KeyTrigger(KeyInput.KEY_LEFT));
	inputManager.addMapping(STRAFE_RIGHT, new KeyTrigger(KeyInput.KEY_D),
			new KeyTrigger(KeyInput.KEY_RIGHT));
	inputManager.addMapping(MOVE_FOREWARD, new KeyTrigger(KeyInput.KEY_Z),
			new KeyTrigger(KeyInput.KEY_UP));
	inputManager.addMapping(MOVE_BACKWARD, new KeyTrigger(KeyInput.KEY_S),
			new KeyTrigger(KeyInput.KEY_DOWN));
	inputManager.addListener(this, mappings);
}
 
开发者ID:methusalah,项目名称:OpenRTS,代码行数:18,代码来源:GroundCameraManager.java

示例9: registerInputs

import com.jme3.input.InputManager; //导入方法依赖的package包/类
@Override
protected void registerInputs(InputManager inputManager) {
	inputManager.addMapping(SWITCH_CTRL_1, new KeyTrigger(KeyInput.KEY_F1));
	inputManager.addMapping(SWITCH_CTRL_2, new KeyTrigger(KeyInput.KEY_F2));
	inputManager.addMapping(SWITCH_CTRL_3, new KeyTrigger(KeyInput.KEY_F3));
	inputManager.addMapping(SELECT, new MouseButtonTrigger(0));
	inputManager.addMapping(ACTION, new MouseButtonTrigger(1));
	inputManager.addMapping(MOVE_ATTACK, new KeyTrigger(KeyInput.KEY_A));
	inputManager.addMapping(MULTIPLE_SELECTION, new KeyTrigger(KeyInput.KEY_LCONTROL),
			new KeyTrigger(KeyInput.KEY_RCONTROL));
	inputManager.addMapping(HOLD, new KeyTrigger(KeyInput.KEY_H));
	inputManager.addMapping(PAUSE, new KeyTrigger(KeyInput.KEY_SPACE));

	inputManager.addListener(this, mappings);

	logger.info("battlefield controller online");
}
 
开发者ID:methusalah,项目名称:OpenRTS,代码行数:18,代码来源:BattlefieldInputInterpreter.java

示例10: registerWithInput

import com.jme3.input.InputManager; //导入方法依赖的package包/类
/**
 * Registers the FlyByCamera to recieve input events from the provided
 * Dispatcher.
 * @param dispacher
 */
public void registerWithInput(InputManager inputManager){
    this.inputManager = inputManager;
   
    String[] mappings = new String[]{
        ROTATINGCAM_Left,
        ROTATINGCAM_Right,
        ROTATINGCAM_Up,
        ROTATINGCAM_Down,
        ROTATINGCAM_ZoomIn,
        ROTATINGCAM_ZoomOut,
    };

    // both mouse and button - rotation of cam
    inputManager.addMapping(ROTATINGCAM_Left, new KeyTrigger(AwtKeyInput.KEY_LEFT));
    inputManager.addMapping(ROTATINGCAM_Right, new KeyTrigger(AwtKeyInput.KEY_RIGHT));
    inputManager.addMapping(ROTATINGCAM_Up, new KeyTrigger(AwtKeyInput.KEY_UP));
    inputManager.addMapping(ROTATINGCAM_Down, new KeyTrigger(AwtKeyInput.KEY_DOWN));
    inputManager.addMapping(ROTATINGCAM_ZoomIn, new KeyTrigger(AwtKeyInput.KEY_ADD));
    inputManager.addMapping(ROTATINGCAM_ZoomOut, new KeyTrigger(AwtKeyInput.KEY_SUBTRACT));
    
    inputManager.addListener(this, mappings);
    inputManager.setCursorVisible(true);
}
 
开发者ID:lyrgard,项目名称:HexScape,代码行数:29,代码来源:RotatingAroundCamera.java

示例11: initialize

import com.jme3.input.InputManager; //导入方法依赖的package包/类
@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);

        appName = app.getClass().getSimpleName();
    }
    
    super.initialize(stateManager, app);
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:17,代码来源:ScreenshotAppState.java

示例12: registerAnalogListener

import com.jme3.input.InputManager; //导入方法依赖的package包/类
/**
 * Register the analog listener.
 *
 * @param inputManager the input manager
 */
@JMEThread
protected void registerAnalogListener(@NotNull final InputManager inputManager) {
    inputManager.addListener(analogListener, MOUSE_X_AXIS, MOUSE_X_AXIS_NEGATIVE, MOUSE_Y_AXIS,
            MOUSE_Y_AXIS_NEGATIVE, MOUSE_MOVE_CAMERA_X_AXIS, MOUSE_MOVE_CAMERA_X_AXIS_NEGATIVE,
            MOUSE_MOVE_CAMERA_Y_AXIS, MOUSE_MOVE_CAMERA_Y_AXIS_NEGATIVE);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:12,代码来源:AdvancedAbstractEditor3DState.java

示例13: registerActionListener

import com.jme3.input.InputManager; //导入方法依赖的package包/类
/**
 * Register the action listener.
 *
 * @param inputManager the input manager
 */
@JMEThread
protected void registerActionListener(@NotNull final InputManager inputManager) {
    inputManager.addListener(actionListener, MOUSE_RIGHT_CLICK, MOUSE_LEFT_CLICK, MOUSE_MIDDLE_CLICK);
    inputManager.addListener(actionListener, KEY_CTRL, KEY_SHIFT, KEY_ALT, KEY_CTRL_S, KEY_CTRL_Z, KEY_CTRL_Y, KEY_NUM_1,
            KEY_NUM_2, KEY_NUM_3, KEY_NUM_4, KEY_NUM_5, KEY_NUM_6, KEY_NUM_7, KEY_NUM_8, KEY_NUM_9, KEY_FLY_CAMERA_W,
            KEY_FLY_CAMERA_S, KEY_FLY_CAMERA_A, KEY_FLY_CAMERA_D);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:13,代码来源:AdvancedAbstractEditor3DState.java

示例14: initialize

import com.jme3.input.InputManager; //导入方法依赖的package包/类
@Override
public void initialize(AppStateManager stateManager, Application app) {
    super.initialize(stateManager, app);

    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);

    appName = app.getClass().getSimpleName();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:15,代码来源:ScreenshotAppState.java

示例15: initKeys

import com.jme3.input.InputManager; //导入方法依赖的package包/类
public void initKeys(InputManager inputManager) {
       inputManager.addMapping(name + "MakeBlock", new KeyTrigger(KeyInput.KEY_B));
       inputManager.addMapping(name + "MakeStack", new KeyTrigger(KeyInput.KEY_N));
       inputManager.addMapping(name + "ClearTable", new KeyTrigger(KeyInput.KEY_C));

       inputManager.addListener(this, "shiftKey");
       
       inputManager.addListener(this, name + "MakeBlock");
       inputManager.addListener(this, name + "MakeStack");
       inputManager.addListener(this, name + "ClearTable");
}
 
开发者ID:dwhuang,项目名称:SMILE,代码行数:12,代码来源:Table.java


注:本文中的com.jme3.input.InputManager.addListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。