com.badlogic.gdx.InputMultiplexer Java Examples
The following examples show how to use
com.badlogic.gdx.InputMultiplexer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GdxScreen.java From libGDX-Path-Editor with Apache License 2.0 | 6 votes |
public GdxScreen(GdxApp gdxApp, int stageW, int stageH, int canvasW, int canvasH) { super(gdxApp); this.screenW = stageW; this.screenH = stageH; camera = new Camera(canvasW, canvasH); camera.position.x = (int)(screenW / 2); camera.position.y = (int)(screenH / 2); stage = new Stage(stageW, stageH, false); stage.setCamera(camera); bgDrawer = new BGDrawer(); inputMultiplexer = new InputMultiplexer(); inputMultiplexer.addProcessor(stage); inputMultiplexer.addProcessor(new InputHandler()); Gdx.input.setInputProcessor(inputMultiplexer); }
Example #2
Source File: PathFinderTests.java From gdx-ai with Apache License 2.0 | 6 votes |
void changeTest (int index) { // Remove the old behavior and its window testsTable.clear(); if (currentTest != null) { if (currentTest.getDetailWindow() != null) currentTest.getDetailWindow().remove(); currentTest.dispose(); } // Add the new behavior and its window currentTest = tests[index]; currentTest.create(); InputMultiplexer im = (InputMultiplexer)Gdx.input.getInputProcessor(); if (im.size() > 1) im.removeProcessor(1); if (currentTest.getInputProcessor() != null) im.addProcessor(currentTest.getInputProcessor()); if (currentTest.getDetailWindow() != null) stage.addActor(currentTest.getDetailWindow()); }
Example #3
Source File: SteeringBehaviorsTest.java From gdx-ai with Apache License 2.0 | 6 votes |
private void changeTest (int engineIndex, int testIndex) { // Remove the old test and its window if (currentTest != null) { if (currentTest.getDetailWindow() != null) currentTest.getDetailWindow().remove(); currentTest.dispose(); } // Add the new test and its window currentTest = tests[engineIndex][testIndex]; currentTest.create(); testHelpLabel.setText(currentTest.getHelpMessage()); InputMultiplexer im = (InputMultiplexer)Gdx.input.getInputProcessor(); if (im.size() > 1) im.removeProcessor(1); if (currentTest.getInputProcessor() != null) im.addProcessor(currentTest.getInputProcessor()); if (currentTest.getDetailWindow() != null) stage.addActor(currentTest.getDetailWindow()); }
Example #4
Source File: GUIConsole.java From libgdx-inGameConsole with Apache License 2.0 | 6 votes |
@Override public void resetInputProcessing () { usesMultiplexer = true; appInput = Gdx.input.getInputProcessor(); if (appInput != null) { if (hasStage(appInput)) { log("Console already added to input processor!", LogLevel.ERROR); Gdx.app.log("Console", "Already added to input processor!"); return; } multiplexer = new InputMultiplexer(); multiplexer.addProcessor(stage); multiplexer.addProcessor(appInput); Gdx.input.setInputProcessor(multiplexer); } else { Gdx.input.setInputProcessor(stage); } }
Example #5
Source File: DefaultSceneScreen.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
@Override public void show() { final InputMultiplexer multiplexer = new InputMultiplexer(); multiplexer.addProcessor(stage); multiplexer.addProcessor(inputProcessor); Gdx.input.setInputProcessor(multiplexer); if (getWorld().isDisposed()) { try { getWorld().load(); } catch (Exception e) { EngineLogger.error("ERROR LOADING GAME", e); dispose(); Gdx.app.exit(); } } getWorld().setListener(worldListener); getWorld().resume(); }
Example #6
Source File: BattleScreen.java From Norii with Apache License 2.0 | 5 votes |
private void initializeInput() { battlescreenInputProcessor = new BattleScreenInputProcessor(this, mapCamera); multiplexer = new InputMultiplexer(); multiplexer.addProcessor(battlescreenInputProcessor); multiplexer.addProcessor(playerBattleHUD.getStage()); multiplexer.addProcessor(Player.getInstance().getEntityStage()); multiplexer.addProcessor(pauseMenu.getStage()); }
Example #7
Source File: PathFinderTests.java From gdx-ai with Apache License 2.0 | 5 votes |
@Override public void create () { Gdx.gl.glClearColor(.3f, .3f, .3f, 1); skin = new Skin(Gdx.files.internal("data/uiskin.json")); // Enable color markup BitmapFont font = skin.get("default-font", BitmapFont.class); font.getData().markupEnabled = true; stage = new Stage(); stage.setDebugAll(DEBUG_STAGE); stageWidth = stage.getWidth(); stageHeight = stage.getHeight(); Gdx.input.setInputProcessor(new InputMultiplexer(stage)); Stack stack = new Stack(); stage.addActor(stack); stack.setSize(stageWidth, stageHeight); testsTable = new Table(); stack.add(testsTable); // Create behavior selection window List<String> testList = createTestList(); algorithmSelectionWindow = addBehaviorSelectionWindow("Path Finder Tests", testList, 0, -1); // Set selected test changeTest(0); stage.addActor(new FpsLabel("FPS: ", skin)); }
Example #8
Source File: Main.java From gdx-proto with Apache License 2.0 | 5 votes |
@Override public void create () { Log.setLevel(Log.DEBUG); platform = Gdx.app.getType(); // we can pretend to be Android while running on desktop to test mobile features // such as mobile-specific input //platform = Application.ApplicationType.Android; Assets assets = new Assets(); assets.loadAll(); Log.debug("finished loading assets"); physics = new Physics(); initializeSubModules(); frame = 0; inst = this; if (isClient()) { view = new View(); new Particles(); input = new Input(); inputMulti = new InputMultiplexer(); inputMulti.addProcessor(View.inst.hud.stage); inputMulti.addProcessor(input); if (isMobile()) { inputMulti.addProcessor(GestureHandler.createGestureHandler()); } Gdx.input.setInputProcessor(inputMulti); } LevelBuilder.createLevel(); setupNetwork(); }
Example #9
Source File: SeventhGame.java From seventh with GNU General Public License v2.0 | 5 votes |
/** * @param config */ public SeventhGame(ClientSeventhConfig config, String startupConfig) throws Exception { this.console = Cons.getImpl(); this.timeStep = new TimeStep(); this.terminal = new Terminal(console, config); this.inputs = new InputMultiplexer(); Cons.println(HEADER); Cons.println("*** Initializing " + VERSION + " ***"); Cons.println("Start Stamp: " + new Date()); this.config = config; this.keyMap = config.getKeyMap(); this.startupConfig = startupConfig; this.connection = new ClientConnection(this, config, console); this.screenStack = new Stack<Screen>(); this.sm = new StateMachine<Screen>(); this.theme = new Theme(); setupCommand(Cons.getImpl()); // Can't set this up here because the // Gdx context hasn't been created yet // this.menuScreen = new MenuScreen(this); }
Example #10
Source File: GUIConsole.java From libgdx-inGameConsole with Apache License 2.0 | 5 votes |
/** * Compares the given processor to the console's stage. If given a multiplexer, it is iterated through recursively to check all * of the multiplexer's processors for comparison. * * @param processor * @return processor == this.stage */ private boolean hasStage (InputProcessor processor) { if (!(processor instanceof InputMultiplexer)) { return processor == stage; } InputMultiplexer im = (InputMultiplexer)processor; SnapshotArray<InputProcessor> ips = im.getProcessors(); for (InputProcessor ip : ips) { if (hasStage(ip)) { return true; } } return false; }
Example #11
Source File: EngineGDX.java From Entitas-Java with MIT License | 5 votes |
@Override public void initialize() { for (Manager manager : _managers.values()) { manager.initialize(); } inputManager.initialize(); guiManagerGDX.initialize(); InputMultiplexer inputMultiplexer = new InputMultiplexer(); inputMultiplexer.addProcessor(inputManager); inputMultiplexer.addProcessor(guiManagerGDX.getStage()); Gdx.input.setInputProcessor(inputMultiplexer); }
Example #12
Source File: DemoScreen.java From cocos-ui-libgdx with Apache License 2.0 | 5 votes |
private void initDemoChange(InputMultiplexer multiplexer) { Stage demoChangeStage = new Stage(new StretchViewport(DemoGame.GAME_WIDTH, DemoGame.GAME_HEIGHT)); Actor actor = new Actor(); actor.setWidth(stage.getWidth()); actor.setHeight(stage.getHeight()); actor.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { updateCurrentIndex(); changeDemo(); } }); demoChangeStage.addActor(actor); multiplexer.addProcessor(demoChangeStage); }
Example #13
Source File: DemoScreen.java From cocos-ui-libgdx with Apache License 2.0 | 5 votes |
@Override public void show() { super.show(); stage = new Stage(new StretchViewport(DemoGame.GAME_WIDTH, DemoGame.GAME_HEIGHT)); InputMultiplexer multiplexer = new InputMultiplexer(); multiplexer.addProcessor(stage); initDemoChange(multiplexer); Gdx.input.setInputProcessor(multiplexer); findAllDemos(); defaultFont = Gdx.files.internal("share/MLFZS.TTF"); changeDemo(); }
Example #14
Source File: GameScreen.java From Unlucky with MIT License | 5 votes |
public GameScreen(final Unlucky game, final ResourceManager rm) { super(game, rm); currentEvent = EventState.MOVING; gameMap = new GameMap(this, game.player, rm); battle = new Battle(this, gameMap.tileMap, gameMap.player); hud = new Hud(this, gameMap.tileMap, gameMap.player, rm); battleUIHandler = new BattleUIHandler(this, gameMap.tileMap, gameMap.player, battle, rm); transition = new TransitionScreen(this, battle, battleUIHandler, hud, gameMap.player, rm); levelUp = new LevelUpScreen(this, gameMap.tileMap, gameMap.player, rm); dialog = new DialogScreen(this, gameMap.tileMap, gameMap.player, rm); // create bg bg = new Background[2]; // sky bg[0] = new Background((OrthographicCamera) battleUIHandler.getStage().getCamera(), new Vector2(0.3f, 0)); // field bg[1] = new Background((OrthographicCamera) battleUIHandler.getStage().getCamera(), new Vector2(0, 0)); // input multiplexer multiplexer = new InputMultiplexer(); multiplexer.addProcessor(hud.getStage()); multiplexer.addProcessor(battleUIHandler.getStage()); multiplexer.addProcessor(levelUp.getStage()); multiplexer.addProcessor(dialog.getStage()); }
Example #15
Source File: PlayScreen.java From xibalba with MIT License | 5 votes |
/** * Play Screen. * * @param main Instance of Main class */ public PlayScreen(Main main) { glProfiler = new GLProfiler(Gdx.graphics); autoTimer = 0; keyHoldTimerDelay = 0; keyHoldTimer = 0; batch = new SpriteBatch(); // Setup camera; OrthographicCamera worldCamera = new OrthographicCamera(); // Setup renderers worldRenderer = new WorldRenderer(worldCamera, batch); hudRenderer = new HudRenderer(main, batch); // Debug console console = new GUIConsole(Main.skin, false); console.setCommandExecutor(new ConsoleCommandExecutor()); console.setSizePercent(100, 50); // Setup input multiplexer = new InputMultiplexer(); playerInput = new PlayerInput(worldCamera); multiplexer.addProcessor(hudRenderer.stage); multiplexer.addProcessor(playerInput); // Player attributes & their god playerAttributes = ComponentMappers.attributes.get(WorldManager.player); god = ComponentMappers.god.get(WorldManager.god); // Generate all dijkstra maps WorldManager.world.getCurrentMap().dijkstra.updateAll(); // Change state to playing WorldManager.state = WorldManager.State.PLAYING; }
Example #16
Source File: MenuScene.java From Skyland with MIT License | 4 votes |
private void initRayCastListener() { Gdx.input.setInputProcessor(new InputMultiplexer(Skyland.STAGE, rayCastListener = new RayCastListener(world, camera))); rayCastListener.initParticleUtils(particleUtils); rayCastListener.initCloudPoofer(cloudGenerator); }
Example #17
Source File: RetroSceneScreen.java From bladecoder-adventure-engine with Apache License 2.0 | 4 votes |
@Override public void show() { retrieveAssets(ui.getUIAtlas()); stage = new Stage(screenViewport); // stage.addActor(textManagerUI); stage.addActor(dialogUI); stage.addActor(menuButton); stage.addActor(verbUI); stage.addActor(pointer); menuButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { ui.setCurrentScreen(Screens.MENU_SCREEN); } }); worldViewportStage = new Stage(worldViewport); worldViewportStage.addActor(textManagerUI); final InputMultiplexer multiplexer = new InputMultiplexer(); multiplexer.addProcessor(stage); multiplexer.addProcessor(inputProcessor); Gdx.input.setInputProcessor(multiplexer); if (ui.getWorld().isDisposed()) { try { ui.getWorld().load(); } catch (Exception e) { EngineLogger.error("ERROR LOADING GAME", e); dispose(); Gdx.app.exit(); } } ui.getWorld().setListener(worldListener); ui.getWorld().resume(); textManagerUI.setText(ui.getWorld().getCurrentScene().getTextManager().getCurrentText()); updateUI(); }
Example #18
Source File: GameScene.java From Skyland with MIT License | 4 votes |
@Override public void show() { initWorld(); Gdx.input.setInputProcessor(new InputMultiplexer(rayCastListener = new RayCastListener(world, camera), new CameraController(camera, -20, 7, -1.5f, 2))); initRayCasting(); }
Example #19
Source File: InputChain.java From Cubes with MIT License | 4 votes |
public static InputMultiplexer getInputMultiplexer() { return inputMultiplexer; }
Example #20
Source File: SteeringBehaviorsTest.java From gdx-ai with Apache License 2.0 | 4 votes |
@Override public void create () { Gdx.gl.glClearColor(.3f, .3f, .3f, 1); greenFish = new TextureRegion(new Texture("data/green_fish.png")); cloud = new TextureRegion(new Texture("data/particle-cloud.png")); badlogicSmall = new TextureRegion(new Texture("data/badlogicsmall.jpg")); target = new TextureRegion(new Texture("data/target.png")); skin = new Skin(Gdx.files.internal("data/uiskin.json")); stage = new Stage(); stage.setDebugAll(DEBUG_STAGE); stageWidth = stage.getWidth(); stageHeight = stage.getHeight(); Gdx.input.setInputProcessor(new InputMultiplexer(stage)); // Add translucent panel (it's only visible when AI is paused) final Image translucentPanel = new Image(skin, "translucent"); translucentPanel.setSize(stageWidth, stageHeight); translucentPanel.setVisible(false); stage.addActor(translucentPanel); // Create test selection window Array<List<String>> engineTests = new Array<List<String>>(); for (int k = 0; k < tests.length; k++) { engineTests.add(createTestList(k)); } testSelectionWindow = addTestSelectionWindow("Behaviors", ENGINES, engineTests, 0, -1); // Create status bar Table statusBar = new Table(skin); statusBar.left().bottom(); statusBar.row().height(26); statusBar.add(pauseButton = new PauseButton(translucentPanel, skin)).width(90).left(); statusBar.add(new FpsLabel("FPS: ", skin)).padLeft(15); statusBar.add(testHelpLabel = new Label("", skin)).padLeft(15); stage.addActor(statusBar); // Set selected behavior changeTest(0, 0); }
Example #21
Source File: BulletSteeringTest.java From gdx-ai with Apache License 2.0 | 4 votes |
protected void setNewTargetInputProcessor (SteeringBulletEntity target, Vector3 offset) { BulletTargetInputProcessor bulletTargetInputProcessor = new BulletTargetInputProcessor(target, offset, viewport, world.collisionWorld); setInputProcessor(new InputMultiplexer(bulletTargetInputProcessor, cameraController)); spaceToMoveTarget = true; }