Example usage for com.badlogic.gdx InputMultiplexer InputMultiplexer

List of usage examples for com.badlogic.gdx InputMultiplexer InputMultiplexer

Introduction

In this page you can find the example usage for com.badlogic.gdx InputMultiplexer InputMultiplexer.

Prototype

public InputMultiplexer() 

Source Link

Usage

From source file:com.theosirian.ppioo.controllers.Controller.java

License:Open Source License

public void start() {
    InputMultiplexer inputMultiplexer = new InputMultiplexer();
    inputMultiplexer.addProcessor(game.stage);
    inputMultiplexer.addProcessor(this);
    createComponents();//ww  w . j a  va 2  s.  co m
    Gdx.input.setInputProcessor(inputMultiplexer);

    game.stage.addActor(rootLayout);
    buildUI();
}

From source file:com.thetruthbeyond.botmaker.BotMaker.java

License:Open Source License

@Override
public void create() {
    try {/*  ww  w  . j  a  va 2  s  . c om*/
        loader = new AssetsLoader();
        loader.initialize();

        Coding.configureCharsets(loader);
        Fonts.configureFonts(loader);

        Keyboard.getInstance().setFilter(Coding.signs);

        InputMultiplexer multiplexer = new InputMultiplexer();
        multiplexer.addProcessor(cursor);
        multiplexer.addProcessor(keyboard);
        Gdx.input.setInputProcessor(multiplexer);
    } catch (Exception exception) {
        Logger logger = new Logger();
        logger.writeMessage("Error occured", "Cause was detected in create() method of BotMaker class.");
        logger.writeError(exception);
    }

    try {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception ignored) {
        // If look and feel could not be found use the default one and do not report a mistake.
    }
}

From source file:com.uwsoft.editor.gdx.sandbox.Sandbox.java

License:Apache License

private void init() {
    inputMultiplexer = new InputMultiplexer();
    Gdx.input.setInputProcessor(inputMultiplexer);
    sandboxStage = new SandboxStage();
    uiStage = new UIStage(sandboxStage);
    sandboxStage.setUIStage(uiStage);/*w w  w .jav  a 2s. c om*/

    inputMultiplexer.addProcessor(uiStage);
    inputMultiplexer.addProcessor(sandboxStage);

    editingMode = EditingMode.SELECTION;

    sceneControl = new SceneControlMediator(sandboxStage.sceneLoader, sandboxStage.essentials);
    itemControl = new ItemControlMediator(sceneControl);

    transformationHandler = new TransformationHandler();
    sandboxInputAdapter = new SandboxInputAdapter(this);
    uac = new UserActionController(this);
    selector = new ItemSelector(this);
    itemFactory = new ItemFactory(this);
}

From source file:com.uwsoft.editor.view.Overlap2DScreen.java

License:Apache License

@Override
public void show() {
    sandbox = Sandbox.getInstance();/*from  www  .j a  va2  s  .c o  m*/
    uiStage = sandbox.getUIStage();
    //sandboxStage = commands.getSandboxStage();

    //sandboxStage.commands = commands;

    projectManager = facade.retrieveProxy(ProjectManager.NAME);
    // check for demo project
    File demoDir = new File(
            projectManager.getRootPath() + File.separator + "examples" + File.separator + "OverlapDemo");
    if (demoDir.isDirectory() && demoDir.exists()) {
        projectManager.openProjectFromPath(demoDir.getAbsolutePath() + File.separator + "project.pit");
        sandbox.loadCurrentProject();
        if (sandbox.getViewport() != null) {
            sandbox.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        }
        facade.sendNotification(ProjectManager.PROJECT_OPENED);
    }
    multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(this);
    multiplexer.addProcessor(uiStage);
    multiplexer.addProcessor(new SandboxInputAdapter());
    Gdx.input.setInputProcessor(multiplexer);
}

From source file:de.caffeineaddicted.sgl.SGLGame.java

License:BEER-WARE LICENSE

public SGLGame(boolean initializeSGL) {
    if (initializeSGL) {
        SGL.game(this);
    }/* w  w w. j  a v  a2 s.  com*/
    supply(SGLScreenInputMultiplexer.class, new SGLScreenInputMultiplexer());
    supply(SGLRootScreen.class, new SGLRootScreen());
    multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(provide(SGLScreenInputMultiplexer.class));
}

From source file:de.gebatzens.meteva.GScout.java

License:Open Source License

@Override
public void create() {

    //For testing
    trace = false;//from   ww  w.  j av  a  2  s  . co m

    if (trace)
        tracei.beginTrace("initmeteva");
    batch = new SpriteBatch();
    atlas = new TextureAtlas(Gdx.files.internal("all.pack"));
    sbg = new SpaceBackground();
    sbg.initBackground();
    settings = new Settings();
    settings.load();
    highscoren = new Highscore();
    highscoren.load(false);
    highscoref = new Highscore();
    highscoref.load(true);
    mprof = new MarketProfile();
    mprof.load();
    mprof.reset();
    Gdx.app.setLogLevel(Application.LOG_ERROR);

    manager = new AssetManager();
    locale = Locale.getDefault();
    bundle = I18NBundle.createBundle(Gdx.files.internal("lang/bundle"), locale);
    Gdx.app.debug("Meteva", "using locale " + locale);

    for (int i = 0; i < 4; i++) {
        meteorExpl[i] = Gdx.audio.newSound(Gdx.files.internal("sounds/expl" + (i + 1) + ".ogg"));
    }
    playerExpl = Gdx.audio.newSound(Gdx.files.internal("sounds/raumschiffexpl.ogg"));
    laser = Gdx.audio.newSound(Gdx.files.internal("sounds/laser.ogg"));
    rush = Gdx.audio.newMusic(Gdx.files.internal("sounds/rush.mp3"));
    rush.setLooping(true);
    if (settings.musicEnabled())
        rush.play();

    Texture tex = new Texture(Gdx.files.internal("survivant.png"));
    tex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    survivant = new BitmapFont(Gdx.files.internal("survivant.fnt"), new TextureRegion(tex), false);
    fontShader = new ShaderProgram(Gdx.files.internal("font.vert"), Gdx.files.internal("font.frag"));

    if (!fontShader.isCompiled()) {
        Gdx.app.error("fontShader", "compilation failed:\n" + fontShader.getLog());
    }

    Pixmap p = new Pixmap(1, 1, Format.RGBA8888);
    p.setColor(Color.WHITE);
    p.drawPixel(0, 0);
    whiteTexture = new Texture(p);
    p.dispose();

    //   camera = new OrthographicCamera(1920, 1080);
    //   camera.setToOrtho(true, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    //   camera.setToOrtho(true);

    InputMultiplexer im = new InputMultiplexer();
    im.addProcessor(this);

    GestureDetector gd = new GestureDetector(this);
    im.addProcessor(gd);

    Gdx.input.setInputProcessor(im);

    width = Gdx.graphics.getWidth();
    height = Gdx.graphics.getHeight();

    musicb = new SoundButton(GScout.width * 0.022f, GScout.height * 0.02f, GScout.getRegion("ton"),
            GScout.getRegion("tonaus"), GScout.width * 0.065f);
    musicb.activated = !settings.musicEnabled();
    soundb = new SoundButton(GScout.width * 0.022f + 0.07f * GScout.width, GScout.height * 0.02f,
            GScout.getRegion("spielton"), GScout.getRegion("spieltonaus"), GScout.width * 0.065f);
    soundb.activated = !settings.soundsEnabled();

    state = new MainState();
    state.init();

    if (trace)
        tracei.endTrace();

}

From source file:de.longri.cachebox3.gui.stages.initial_tasks.GdxInitialTask.java

License:Open Source License

@Override
public void runnable() {
    InputMultiplexer inputMultiplexer = new InputMultiplexer();
    StageManager.setInputMultiplexer(inputMultiplexer);
    Gdx.input.setInputProcessor(inputMultiplexer);
}

From source file:de.longri.cachebox3.gui.views.MapView.java

License:Open Source License

private void createMapInputHandler() {
    GestureDetector gestureDetector = new GestureDetector(new GestureHandlerImpl(mMap));
    MotionHandler motionHandler = new MotionHandler(mMap);
    MapInputHandler inputHandler = new MapInputHandler(mMap);
    mapInputHandler = new InputMultiplexer();
    mapInputHandler.addProcessor(gestureDetector);
    mapInputHandler.addProcessor(motionHandler);
    mapInputHandler.addProcessor(inputHandler);
}

From source file:dk.sidereal.lumm.architecture.core.Input.java

License:Apache License

/**
 * Constructor for input, does not have any connection to the LibGDX backend
 * yet. Is called in/*from   ww  w.  j a  va2  s .  co m*/
 * {@link Lumm#Lumm(LummScene, LummConfiguration)}
 * .
 */
public Input(LummConfiguration cfg) {
    // TODO dude cmon
    super(cfg);
    setUpdateFrequency(0);

    inputData = new ObjectMap<Integer, ActionData>();
    touchInputData = new ObjectMap<Integer, TouchData>();

    inputMultiplexer = new InputMultiplexer();
    inputProcessors = new ObjectMap<String, InputProcessor>();

    actionEvents = new ObjectMap<InputProcessor, ArrayList<ActionEventWrapper>>();
    touchEvents = new ObjectMap<InputProcessor, ArrayList<TouchEventWrapper>>();
    scrollEvents = new ObjectMap<InputProcessor, ArrayList<OnScrollListener>>();
    keyTypedEvents = new ObjectMap<InputProcessor, ArrayList<OnKeyTypedListener>>();

    if (cfg.inputProcessorNames == null || cfg.inputProcessorNames.length == 0)
        this.processorNames = new String[] { DEFAULT_INPUT_PROCESSOR };
    else
        this.processorNames = cfg.inputProcessorNames;
}

From source file:edu.lehigh.cse.lol.Level.java

License:Open Source License

/**
 * Construct a level. This is mostly using defaults, so the main work is in
 * camera setup/*w w w.  jav  a2  s  . c  o  m*/
 *
 * @param width  The width of the level, in meters
 * @param height The height of the level, in meters
 */
Level(int width, int height) {
    // clear any timers
    Timer.instance().clear();

    // Set up listeners for touch events. Gestures are processed before
    // non-gesture touches, and non-gesture touches are only processed when
    // a gesture is not detected.
    InputMultiplexer mux = new InputMultiplexer();
    mux.addProcessor(new GestureDetector(new LolGestureManager()));
    mux.addProcessor(new LolInputManager());
    Gdx.input.setInputProcessor(mux);

    // reset the per-level object store
    mLevelFacts = new TreeMap<>();
    mLevelActors = new TreeMap<>();

    // save the camera bounds
    mCamBoundX = width;
    mCamBoundY = height;

    // warn on strange dimensions
    if (width < Lol.sGame.mWidth / Physics.PIXEL_METER_RATIO)
        Util.message("Warning", "Your game width is less than 1/10 of the screen width");
    if (height < Lol.sGame.mHeight / Physics.PIXEL_METER_RATIO)
        Util.message("Warning", "Your game height is less than 1/10 of the screen height");

    // set up the game camera, with 0,0 in the bottom left
    mGameCam = new OrthographicCamera(Lol.sGame.mWidth / Physics.PIXEL_METER_RATIO,
            Lol.sGame.mHeight / Physics.PIXEL_METER_RATIO);
    mGameCam.position.set(Lol.sGame.mWidth / Physics.PIXEL_METER_RATIO / 2,
            Lol.sGame.mHeight / Physics.PIXEL_METER_RATIO / 2, 0);
    mGameCam.zoom = 1;

    // set up the heads-up display camera
    int camWidth = Lol.sGame.mWidth;
    int camHeight = Lol.sGame.mHeight;
    mHudCam = new OrthographicCamera(camWidth, camHeight);
    mHudCam.position.set(camWidth / 2, camHeight / 2, 0);

    // the background camera is like the hudcam
    mBgCam = new ParallaxCamera(camWidth, camHeight);
    mBgCam.position.set(camWidth / 2, camHeight / 2, 0);
    mBgCam.zoom = 1;

    // set up the renderables
    for (int i = 0; i < 5; ++i)
        mRenderables.add(new ArrayList<Renderable>());

    // set up the callback for finding out who in the physics world was
    // touched
    mTouchCallback = new QueryCallback() {
        @Override
        public boolean reportFixture(Fixture fixture) {
            // if the hit point is inside the fixture of the body we report
            // it
            if (fixture.testPoint(mTouchVec.x, mTouchVec.y)) {
                Actor hs = (Actor) fixture.getBody().getUserData();
                if (hs.mVisible) {
                    mHitActor = hs;
                    return false;
                }
            }
            return true;
        }
    };
}