/** * 触发指定事件 * * @param actions * @param timer */ private void updateAction(Map actions, int type, long timer) { int length = actions.size(); if (length == 0) { return; } Action keyAction = null; switch (type) { case 0: keyAction = (Action) actions.get(String.valueOf(keyPressed[this.pressedKey])); break; case 1: keyAction = (Action) actions.get(String.valueOf(mousePressed[this.pressedMouse])); break; } if (keyAction != null) { if (keyAction.isPressed()) { IAction action = keyAction.getIAction(); action.doAction(timer); if (!(action instanceof MoveAction)) { keyAction.reset(); } } } }