Java Code Examples for com.badlogic.gdx.InputMultiplexer#addProcessor()

The following examples show how to use com.badlogic.gdx.InputMultiplexer#addProcessor() . 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: GUIConsole.java    From libgdx-inGameConsole with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: DefaultSceneScreen.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: SteeringBehaviorsTest.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
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: PathFinderTests.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
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 5
Source File: GdxScreen.java    From libGDX-Path-Editor with Apache License 2.0 6 votes vote down vote up
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 6
Source File: PlayScreen.java    From xibalba with MIT License 5 votes vote down vote up
/**
 * 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 7
Source File: BattleScreen.java    From Norii with Apache License 2.0 5 votes vote down vote up
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 8
Source File: GameScreen.java    From Unlucky with MIT License 5 votes vote down vote up
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 9
Source File: DemoScreen.java    From cocos-ui-libgdx with Apache License 2.0 5 votes vote down vote up
@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 10
Source File: DemoScreen.java    From cocos-ui-libgdx with Apache License 2.0 5 votes vote down vote up
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 11
Source File: EngineGDX.java    From Entitas-Java with MIT License 5 votes vote down vote up
@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: Main.java    From gdx-proto with Apache License 2.0 5 votes vote down vote up
@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 13
Source File: RetroSceneScreen.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
@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();
}