List of usage examples for com.badlogic.gdx InputMultiplexer InputMultiplexer
public InputMultiplexer()
From source file:at.tugraz.ist.catroid.stage.StageListener.java
License:Open Source License
public void create() { font = new BitmapFont(); font.setColor(1f, 0f, 0.05f, 1f);// w ww . ja va 2 s. co m font.setScale(1.2f); pathForScreenshot = Utils.buildProjectPath(ProjectManager.getInstance().getCurrentProject().getName()) + "/"; costumeComparator = new CostumeComparator(); project = ProjectManager.getInstance().getCurrentProject(); virtualWidth = project.virtualScreenWidth; virtualHeight = project.virtualScreenHeight; virtualWidthHalf = virtualWidth / 2; virtualHeightHalf = virtualHeight / 2; screenMode = ScreenModes.STRETCH; stage = new Stage(virtualWidth, virtualHeight, true); batch = stage.getSpriteBatch(); camera = (OrthographicCamera) stage.getCamera(); camera.position.set(0, 0, 0); sprites = project.getSpriteList(); for (Sprite sprite : sprites) { stage.addActor(sprite.costume); } if (DEBUG) { OrthoCamController camController = new OrthoCamController(camera); InputMultiplexer multiplexer = new InputMultiplexer(); multiplexer.addProcessor(camController); multiplexer.addProcessor(stage); Gdx.input.setInputProcessor(multiplexer); fpsLogger = new FPSLogger(); } else { Gdx.input.setInputProcessor(stage); } background = new Texture(Gdx.files.internal("stage/white_pixel.bmp")); axes = new Texture(Gdx.files.internal("stage/red_pixel.bmp")); }
From source file:aurelienribon.texturepackergui.Canvas.java
License:Apache License
@Override public void create() { Assets.loadAll();//from www.j a va2s. c o m Texture.setEnforcePotImages(false); batch = new SpriteBatch(); font = new BitmapFont(); camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); camera.update(); infoLabel = new Sprite(Assets.getWhiteTex()); infoLabel.setPosition(0, 0); infoLabel.setSize(140, 80); infoLabel.setColor(new Color(0x2A / 255f, 0x3B / 255f, 0x56 / 255f, 180 / 255f)); int lblH = 25; Color lblC = new Color(0x2A / 255f, 0x6B / 255f, 0x56 / 255f, 180 / 255f); lblNextPage = new Label(10 + lblH, 120, lblH, "Next page", font, lblC, Anchor.TOP_RIGHT); lblPreviousPage = new Label(15 + lblH * 2, 120, lblH, "Previous page", font, lblC, Anchor.TOP_RIGHT); lblNextPage.setCallback(new Label.TouchCallback() { @Override public void touchDown(Label source) { nextPageRequested = true; } }); lblPreviousPage.setCallback(new Label.TouchCallback() { @Override public void touchDown(Label source) { previousPageRequested = true; } }); lblNextPage.show(); lblPreviousPage.show(); bgTex = Assets.getTransparentLightTex(); bgTex.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat); inputMultiplexer = new InputMultiplexer(); inputMultiplexer.addProcessor(new PanZoomInputProcessor(this)); inputMultiplexer.addProcessor(buttonsInputProcessor); Gdx.input.setInputProcessor(inputMultiplexer); }
From source file:ca.hiphiparray.amazingmaze.SettingsScreen.java
License:Open Source License
/** * Create a new SettingsScreen.//from w w w. j av a 2s .c om * * @param game Instance of AmazingMazeGame to be used */ public SettingsScreen(final AmazingMazeGame game) { this.game = game; this.sourceScreen = game.menuScreen; settings = new Stage(new ScreenViewport(), this.game.batch); multiplexer = new InputMultiplexer(); multiplexer.addProcessor(settings); multiplexer.addProcessor(this); table = new Table(); table.top(); table.setFillParent(true); controlsTable = new Table(); settings.addActor(table); Skin skin = game.assets.skin; screenHeader = new Label("Settings", game.assets.skin, Assets.SANS_HEADER_STYLE); musicSlider = new Slider(0, 1, 0.1f, false, game.assets.skin); musicSlider.setValue(game.save.getMusicLevel()); musicSlider.setAnimateDuration(0.25f); musicSlider.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { game.music.setVolume(musicSlider.getValue()); game.save.setMusicLevel(game.music.getVolume()); } }); musicSliderLabel = new Label("Music Volume", game.assets.skin); controlsHeader = new Label("Controls", game.assets.skin); actions = new Label[] { new Label("Up", game.assets.skin), new Label("Down", game.assets.skin), new Label("Left", game.assets.skin), new Label("Right", game.assets.skin), new Label("Pause", game.assets.skin) }; actionControls = new TextButton[] { new TextButton(Keys.toString(game.save.getUpButton()), skin), new TextButton(Keys.toString(game.save.getDownButton()), skin), new TextButton(Keys.toString(game.save.getLeftButton()), skin), new TextButton(Keys.toString(game.save.getRightButton()), skin), new TextButton(Keys.toString(game.save.getPauseButton()), skin) }; actionControls[0].addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (actionControls[0].isPressed()) { updateControls(0); } } }); actionControls[1].addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (actionControls[1].isPressed()) { updateControls(1); } } }); actionControls[2].addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (actionControls[2].isPressed()) { updateControls(2); } } }); actionControls[3].addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (actionControls[3].isPressed()) { updateControls(3); } } }); actionControls[4].addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (actionControls[4].isPressed()) { updateControls(4); } } }); // Reset settings button resetSettingsButton = new TextButton("Reset Settings", skin); resetSettingsButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (resetSettingsButton.isPressed()) { game.save.resetSettings(); musicSlider.setValue(game.save.getMusicLevel()); resetActionControlsLabels(); } } }); // Reset save button. resetSaveButton = new TextButton("Reset Save", skin); resetSaveButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (resetSaveButton.isPressed()) { game.save.resetSave(); } } }); backButton = new TextButton("Back", skin); }
From source file:com.andgate.ikou.view.GameScreen.java
License:Open Source License
public GameScreen(Ikou game, Level level, int currentFloorNumber) { this.game = game; this.level = level; batch = new SpriteBatch(); TilePalette palette = level.getFloor(currentFloorNumber).getPalette(); Color bg = palette.background; game.bloom.setClearColor(bg.r, bg.g, bg.b, bg.a); Gdx.graphics.setVSync(false);/*from w ww . j a va 2s . c om*/ camera = new PerspectiveCamera(Constants.DEFAULT_FIELD_OF_VIEW, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); modelBatch = new ModelBatch(); levelRender = new LevelRender(level); levelRender.setCamera(camera); levelRender.resetTransform(); levelRender.offsetFloors(); levelRender.spaceFloors(Constants.FLOOR_SPACING); player = new Player(game, level, currentFloorNumber); createEnvironment(); setupCamera(); InputProcessor moveController = new PlayerDirectionGestureDetector(player, camController); im = new InputMultiplexer(); im.addProcessor(moveController); Gdx.input.setInputProcessor(im); controlsMenu = new GameControlsMenu(game, im, moveController, camController); }
From source file:com.andgate.pokeadot.GameScreen.java
License:Open Source License
public GameScreen(final PokeADot newGame, PokeADot.GameMode newMode) { game = newGame;//from ww w . jav a 2 s .co m game.mode = newMode; im = new InputMultiplexer(); im.addProcessor(new GameInputProcessor()); Gdx.input.setInputProcessor(im); pokables = new Array<Pokable>(); pokablesExpired = 0; forceSpawn(); buildStages(); /*im.setProcessors(new Array<InputProcessor>( new InputProcessor[]{new GameInputProcessor()} ));*/ }
From source file:com.badlogic.gdx.tests.Box2DTestCollection.java
License:Apache License
@Override public void create() { if (this.app == null) { this.app = Gdx.app; Box2DTest test = tests[testIndex]; test.create();// ww w.j a va 2s .c o m } InputMultiplexer multiplexer = new InputMultiplexer(); multiplexer.addProcessor(this); multiplexer.addProcessor(new GestureDetector(this)); Gdx.input.setInputProcessor(multiplexer); }
From source file:com.bitfire.postprocessing.demo.PostProcessingDemo.java
License:Apache License
@Override public void create() { ShaderLoader.BasePath = "shaders/"; plex = new InputMultiplexer(); plex.addProcessor(this); Gdx.input.setInputProcessor(plex);/* w ww. ja va 2 s . c om*/ post = new PostProcessing(); createScene(); ui = new UI(plex, post, UsePanelAnimator); }
From source file:com.bladecoder.engine.ui.defaults.DefaultSceneScreen.java
License:Apache License
@Override public void show() { retrieveAssets(ui.getUIAtlas());//w w w . j a va2s.co m stage = new Stage(viewport); stage.addActor(textManagerUI); stage.addActor(dialogUI); stage.addActor(inventoryButton); stage.addActor(menuButton); stage.addActor(inventoryUI); stage.addActor(pie); menuButton.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { ui.setCurrentScreen(Screens.MENU_SCREEN); } }); final InputMultiplexer multiplexer = new InputMultiplexer(); multiplexer.addProcessor(stage); multiplexer.addProcessor(inputProcessor); Gdx.input.setInputProcessor(multiplexer); if (World.getInstance().isDisposed()) { try { World.getInstance().load(); } catch (Exception e) { EngineLogger.error("ERROR LOADING GAME", e); dispose(); Gdx.app.exit(); } } World.getInstance().resume(); }
From source file:com.bladecoder.engine.ui.retro.RetroSceneScreen.java
License:Apache License
@Override public void show() { retrieveAssets(ui.getUIAtlas());/* w w w . j a v a 2s . c o m*/ stage = new Stage(screenViewport); // stage.addActor(textManagerUI); stage.addActor(dialogUI); stage.addActor(menuButton); stage.addActor(verbUI); stage.addActor(pointer); menuButton.addListener(new ClickListener() { 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 (World.getInstance().isDisposed()) { try { World.getInstance().load(); } catch (Exception e) { EngineLogger.error("ERROR LOADING GAME", e); dispose(); Gdx.app.exit(); } } World.getInstance().resume(); }
From source file:com.dongbat.game.util.InputUtil.java
public static void init() { multiplexer = new InputMultiplexer(); Gdx.input.setInputProcessor(multiplexer); }