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:hku.fyp14017.blencode.stage.StageListener.java

License:Open Source License

@Override
public void create() {
    font = new BitmapFont();
    font.setColor(1f, 0f, 0.05f, 1f);/*from   ww  w  .  ja  va 2 s  . co m*/
    font.setScale(1.2f);

    project = ProjectManager.getInstance().getCurrentProject();
    pathForScreenshot = Utils.buildProjectPath(project.getName()) + "/";

    virtualWidth = project.getXmlHeader().virtualScreenWidth;
    virtualHeight = project.getXmlHeader().virtualScreenHeight;

    virtualWidthHalf = virtualWidth / 2;
    virtualHeightHalf = virtualHeight / 2;

    stage = new Stage(virtualWidth, virtualHeight, true);
    batch = stage.getSpriteBatch();

    Gdx.gl.glViewport(0, 0, ScreenValues.SCREEN_WIDTH, ScreenValues.SCREEN_HEIGHT);
    initScreenMode();

    sprites = project.getSpriteList();
    for (Sprite sprite : sprites) {
        sprite.resetSprite();
        sprite.look.createBrightnessContrastShader();
        stage.addActor(sprite.look);
        sprite.resume();
    }

    passepartout = new Passepartout(ScreenValues.SCREEN_WIDTH, ScreenValues.SCREEN_HEIGHT,
            maximizeViewPortWidth, maximizeViewPortHeight, virtualWidth, virtualHeight);
    stage.addActor(passepartout);

    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);
    }

    axes = new Texture(Gdx.files.internal("stage/red_pixel.bmp"));
    skipFirstFrameForAutomaticScreenshot = true;
    if (checkIfAutomaticScreenshotShouldBeTaken) {
        makeAutomaticScreenshot = project.manualScreenshotExists(SCREENSHOT_MANUAL_FILE_NAME);
    }

}

From source file:inputHandling.InputHandler.java

public void setInputSource(Stage stage) {
    multiInput = new InputMultiplexer();
    keyboardInput = new KeyboardInputProcessor();
    xboxInput = new XboxInputProcessor();

    multiInput.addProcessor(stage);//from  w  w  w  .ja va 2s. c  o m
    multiInput.addProcessor(keyboardInput);
    multiInput.addProcessor(xboxInput);

    Controllers.addListener(xboxInput);
    Gdx.input.setInputProcessor(multiInput);
}

From source file:ludowars.core.gui.LayerManager.java

public LayerManager() {
    layers = new ArrayList<Layer>();
    multiplexer = new InputMultiplexer();
    Gdx.input.setInputProcessor(multiplexer);
}

From source file:net.bplaced.therefactory.voraciousviper.screens.GameScreen.java

License:Open Source License

public GameScreen(SpriteBatch batch, ShapeRenderer shapeRenderer, FitViewport viewport,
        OrthographicCamera camera, AssetManager assetManager, TextureAtlas textureAtlas, BitmapFont font) {
    this.batch = batch;
    this.shapeRenderer = shapeRenderer;
    this.font = font;
    this.textureAtlas = textureAtlas;
    this.assetManager = assetManager;
    hud = new Hud(this, font, textureAtlas);
    level = Level.fromFile(this, Gdx.files.internal("levels/original.pack"), textureAtlas);
    hud.setLevel(level);//from  ww w . j  a  v a 2 s  .c  o  m
    this.viewport = viewport;
    this.camera = camera;
    currentGameState = GameState.LevelTransition;
    particles = new Particles(textureAtlas);

    rectangleMenuDialog = new Rectangle();
    rectangleMenuDialog.setSize(260, 160);
    rectangleMenuDialog.setPosition(viewport.getWorldWidth() / 2 - rectangleMenuDialog.getWidth() / 2, 100);

    stage = new Stage();
    stage.setViewport(viewport);
    Skin skin = new Skin();
    skin.addRegions(textureAtlas);

    int buttonWidth = 120;
    int buttonHeight = 70;

    // pause menu dialog
    buttonsPauseDialog = new RetroBundleTextButton[] { new RetroBundleTextButton(shapeRenderer, buttonWidth,
            buttonHeight, VoraciousViper.getInstance().getAmigaFont(), I18NKeys.MainMenu, new ClickListener() {
                @Override
                public void clicked(InputEvent event, float x, float y) {
                    super.clicked(event, x, y);
                    VoraciousViper.getInstance().showTitleScreen();
                }
            }), new RetroBundleTextButton(shapeRenderer, buttonWidth, buttonHeight,
                    VoraciousViper.getInstance().getAmigaFont(), I18NKeys.Restart, new ClickListener() {
                        @Override
                        public void clicked(InputEvent event, float x, float y) {
                            super.clicked(event, x, y);
                            level.reset();
                        }
                    }),
            new RetroBundleTextButton(shapeRenderer, buttonWidth, buttonHeight,
                    VoraciousViper.getInstance().getAmigaFont(), I18NKeys.Continue, new ClickListener() {
                        @Override
                        public void clicked(InputEvent event, float x, float y) {
                            super.clicked(event, x, y);
                            setState(previousGameState);
                        }
                    }) };
    positionButtons(buttonsPauseDialog);

    // game over dialog
    buttonsGameOverDialog = new RetroBundleTextButton[] { new RetroBundleTextButton(shapeRenderer, buttonWidth,
            buttonHeight, VoraciousViper.getInstance().getAmigaFont(), I18NKeys.MainMenu, new ClickListener() {
                @Override
                public void clicked(InputEvent event, float x, float y) {
                    super.clicked(event, x, y);
                    VoraciousViper.getInstance().showTitleScreen();
                }
            }), new RetroBundleTextButton(shapeRenderer, buttonWidth, buttonHeight,
                    VoraciousViper.getInstance().getAmigaFont(), I18NKeys.ScoreTable, new ClickListener() {
                        @Override
                        public void clicked(InputEvent event, float x, float y) {
                            super.clicked(event, x, y);
                            VoraciousViper.getInstance().showScoreTable();
                        }
                    }),
            new RetroBundleTextButton(shapeRenderer, buttonWidth, buttonHeight,
                    VoraciousViper.getInstance().getAmigaFont(), I18NKeys.PlayAgain, new ClickListener() {
                        @Override
                        public void clicked(InputEvent event, float x, float y) {
                            super.clicked(event, x, y);
                            level.reset();
                        }
                    }) };
    positionButtons(buttonsGameOverDialog);

    // continue dialog
    buttonsContinueDialog = new RetroBundleTextButton[] { new RetroBundleTextButton(shapeRenderer, buttonWidth,
            buttonHeight, VoraciousViper.getInstance().getAmigaFont(), I18NKeys.ResetText, new ClickListener() {
                @Override
                public void clicked(InputEvent event, float x, float y) {
                    super.clicked(event, x, y);
                    setState(GameState.ViperCrashed);
                }
            }), new RetroBundleTextButton(shapeRenderer, buttonWidth, buttonHeight,
                    VoraciousViper.getInstance().getAmigaFont(), I18NKeys.ContinueLevel, new ClickListener() {
                        @Override
                        public void clicked(InputEvent event, float x, float y) {
                            super.clicked(event, x, y);
                            getLevel().removeViper();
                            getViper().decrementLives();
                            getViper().setHasCrashed(false);
                            getViper().restart(false);
                            setState(GameState.GameIsBeginning);
                        }
                    }) };
    positionButtons(buttonsContinueDialog);

    inputMultiplexer = new InputMultiplexer();
    inputMultiplexer.addProcessor(0, stage);
    updateGameScreenControls();
}

From source file:net.bplaced.therefactory.voraciousviper.screens.TitleScreen.java

License:Open Source License

public TitleScreen(ShapeRenderer shapeRenderer, final FitViewport viewport, OrthographicCamera camera,
        AssetManager assetManager, TextureAtlas textureAtlas, BitmapFont font) {
    this.instance = this;
    this.shapeRenderer = shapeRenderer;
    this.camera = camera;
    this.assetManager = assetManager;
    this.font = font;
    this.viewport = viewport;
    this.prefs = SettingsManager.getInstance().get();
    this.keyboardInputListener = new KeyboardInputListener(this);
    this.state = TitleScreenState.ShowMainMenu;
    this.stringBuilder = new StringBuilder();

    if (SettingsManager.getInstance().isMusicEnabled())
        VoraciousViper.getInstance().playMusicFile(true);

    paddingFromViewport = 10;/*from  w  w  w  .j  av a2  s  .c  o m*/
    int hSpaceBetweenButtons = 10;
    vSpaceBetweenButtons = 20;

    camera.position.set(viewport.getWorldWidth() / 2, viewport.getWorldHeight() / 2, 0);
    camera.update();

    if (Config.SHOW_BADGE) {
        spriteBadge = new Sprite(new Texture("google-play-badge.png"));
    }
    spriteTitle = new Sprite(new Texture("title.png"));
    rectangleTitle = new Rectangle(viewport.getWorldWidth() / 2 - spriteTitle.getWidth() / 2 + xOffset, 200,
            spriteTitle.getWidth(), spriteTitle.getHeight());
    rectangleTitleScoreTable = new Rectangle(8, viewport.getWorldHeight() - 40, rectangleTitle.width / 2,
            rectangleTitle.height / 2);
    spriteTitle.setBounds(rectangleTitle.x, rectangleTitle.y, rectangleTitle.width, rectangleTitle.height);

    spriteInfo = textureAtlas.createSprite("Info");
    spriteSettings = textureAtlas.createSprite("settings");
    spriteThere = new Sprite(new Texture("there.png"));
    spriteFactory = new Sprite(new Texture("factory.png"));
    spriteDownload = new Sprite(new Texture("download.png"));
    spriteStar = new Sprite(new Texture("star.png"));

    indexCurrentHeadSprite = 0;
    spritesViperHeads = new Sprite[6];
    spritesViperHeads[0] = textureAtlas.createSprite("Head.X.1.Green");
    spritesViperHeads[1] = textureAtlas.createSprite("Head.X.2.Green");
    spritesViperHeads[2] = textureAtlas.createSprite("Head.X.1.Purple");
    spritesViperHeads[3] = textureAtlas.createSprite("Head.X.2.Purple");
    spritesViperHeads[4] = textureAtlas.createSprite("Head.X.1.Blue");
    spritesViperHeads[5] = textureAtlas.createSprite("Head.X.2.Blue");

    stage = new Stage();
    stage.setViewport(this.viewport);
    Skin skin = new Skin();
    skin.addRegions(textureAtlas);

    // button to close settings
    buttonClose = new RetroTextButton(shapeRenderer, 52, 52, font, "X", new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            setState(TitleScreenState.ShowMainMenu);
        }
    });
    buttonClose.setPosition(viewport.getWorldWidth() - buttonClose.getWidth() - vSpaceBetweenButtons,
            viewport.getWorldHeight() - buttonClose.getHeight() - vSpaceBetweenButtons);
    buttonClose.setThickness(3);
    stage.addActor(buttonClose);

    // button to show about screen
    buttonSwitchBetweenAboutAndSettings = new RetroTextButton(shapeRenderer, 52, 52, font, "?",
            new ClickListener() {
                @Override
                public void clicked(InputEvent event, float x, float y) {
                    super.clicked(event, x, y);
                    if (state.equals(TitleScreenState.ShowSettings)) { // toggle about screen
                        setState(TitleScreenState.ShowAbout);
                    } else {
                        setState(TitleScreenState.ShowSettings);
                    }
                }
            });
    buttonSwitchBetweenAboutAndSettings.setPosition(
            buttonClose.getX() - buttonSwitchBetweenAboutAndSettings.getWidth() - hSpaceBetweenButtons,
            buttonClose.getY());
    stage.addActor(buttonSwitchBetweenAboutAndSettings);

    // button to rate app
    buttonRate = new RetroTextButton(shapeRenderer, 100, 52, font, "Rate", new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            Gdx.net.openURI(URL_TO_PLAY_STORE);
        }
    });
    buttonRate.setPosition(250, buttonSwitchBetweenAboutAndSettings.getY());
    stage.addActor(buttonRate);

    // button to view the soundtrack
    buttonSoudtrack = new RetroTextButton(shapeRenderer, 100, 52, font, "Soundtrack", new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            Gdx.net.openURI(URL_TO_SOUNDTRACK);
        }
    });
    buttonSoudtrack.setPosition(370, buttonSwitchBetweenAboutAndSettings.getY());
    stage.addActor(buttonSoudtrack);

    // initialize buttons for main menu
    int buttonSize = 130;
    buttonsMainMenu = new RetroBundleTextButton[] { new RetroBundleTextButton(shapeRenderer, buttonSize, 100,
            font, I18NKeys.Singleplayer, new ClickListener() {
                @Override
                public void clicked(InputEvent event, float x, float y) {
                    super.clicked(event, x, y);
                    VoraciousViper.getInstance().startGame();
                }
            }), new RetroBundleTextButton(shapeRenderer, buttonSize, 100, font, I18NKeys.ScoreTable,
                    new ClickListener() {
                        @Override
                        public void clicked(InputEvent event, float x, float y) {
                            super.clicked(event, x, y);
                            showScoreTable();
                        }
                    }),
            new RetroBundleTextButton(shapeRenderer, buttonSize, 100, font, I18NKeys.Settings,
                    new ClickListener() {
                        @Override
                        public void clicked(InputEvent event, float x, float y) {
                            super.clicked(event, x, y);
                            setState(TitleScreenState.ShowSettings);
                        }
                    }),
            new RetroBundleTextButton(shapeRenderer, buttonSize, 100, font, I18NKeys.About,
                    new ClickListener() {
                        @Override
                        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                            super.touchUp(event, x, y, pointer, button);
                            if (Config.SHOW_BADGE) {
                                setState(TitleScreenState.ShowBadge);
                            } else {
                                setState(TitleScreenState.ShowAbout);
                            }
                        }
                    }) };
    for (RetroTextButton textButton : buttonsMainMenu) {
        textButton.setPosition(paddingFromViewport, paddingFromViewport);
        textButton.setAlignment(TextAlign.CenterBottom);
        stage.addActor(textButton);
    }

    buttonSize = 52;

    // initialize buttons for settings menu
    buttonsSettings = new AbstractRetroButton[][] {
            new RetroImageButton[] {
                    new RetroImageButton(shapeRenderer, buttonSize, buttonSize, skin.getDrawable("flag_usa"),
                            PrefsKeys.Language, Locale.ENGLISH.toString()),
                    new RetroImageButton(shapeRenderer, buttonSize, buttonSize,
                            skin.getDrawable("flag_austria"), PrefsKeys.Language, Locale.GERMAN.toString()) },
            new RetroImageToggleButton[] {
                    new RetroImageToggleButton(shapeRenderer, buttonSize, buttonSize,
                            skin.getDrawable("music.on"), skin.getDrawable("music.off"), PrefsKeys.Music, true),
                    new RetroImageToggleButton(shapeRenderer, buttonSize, buttonSize,
                            skin.getDrawable("sound.on"), skin.getDrawable("sound.off"), PrefsKeys.Sound,
                            true) },
            new RetroTextButton[] { new RetroTextButton(shapeRenderer, buttonSize, buttonSize, font,
                    I18NKeys.Playername, new ClickListener() {
                        @Override
                        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                            super.touchUp(event, x, y, pointer, button);
                            Gdx.input.getTextInput(keyboardInputListener,
                                    VoraciousViper.getInstance().getBundle()
                                            .get(I18NKeys.PleaseEnterYourPlayername),
                                    SettingsManager.getInstance().get().getString(PrefsKeys.PlayerName), "");
                        }
                    }) },
            new RetroImageButton[] { new RetroImageButton(shapeRenderer, buttonSize, buttonSize,
                    skin.getDrawable("controls_touchareas"), PrefsKeys.Controls, PrefsKeys.ControlsTouchAreas),
                    new RetroImageButton(shapeRenderer, buttonSize, buttonSize,
                            skin.getDrawable("controls_touchpad"), PrefsKeys.Controls,
                            PrefsKeys.ControlsTouchPad),
                    new RetroImageButton(shapeRenderer, buttonSize, buttonSize,
                            skin.getDrawable("controls_relative"), PrefsKeys.Controls,
                            PrefsKeys.ControlsRelative),
            //               new RetroImageButton(shapeRenderer, buttonSize, buttonSize, skin.getDrawable("controls_swipe"),
            //                     PrefsKeys.Controls, PrefsKeys.ControlsSwipe),
            //               new RetroImageButton(shapeRenderer, buttonSize, buttonSize, skin.getDrawable("controls_joystick"),
            //                     PrefsKeys.Controls, PrefsKeys.ControlsJoystick)
            }, };

    // listeners to change locale in settings manager
    ClickListener clickListener = new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            VoraciousViper.getInstance().setLocale(prefs.getString(PrefsKeys.Language));
            updatePlayernameText();
        }
    };
    buttonsSettings[0][0].addListener(clickListener);
    buttonsSettings[0][1].addListener(clickListener);
    ((RetroTextButton) buttonsSettings[2][0]).setAutoSize(true);
    buttonsSettings[1][0].addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            if (SettingsManager.getInstance().isMusicEnabled()) {
                VoraciousViper.getInstance().playMusicFile(true);
            } else {
                VoraciousViper.getInstance().pauseMusic();
            }
        }
    });

    // equally distribute settings buttons based on the defined buttonSize
    for (int i = 0; i < buttonsSettings.length; i++) {
        for (int j = 0; j < buttonsSettings[i].length; j++) {
            buttonsSettings[i][j].setPosition(vSpaceBetweenButtons + j * (buttonSize + hSpaceBetweenButtons),
                    vSpaceBetweenButtons * 2
                            + (buttonsSettings.length - 1 - i) * (vSpaceBetweenButtons + buttonSize));
            int pointer = 0;
            if (i == 0 || i == 3) {
                AbstractRetroButton[] adjacentButtons = new AbstractRetroButton[buttonsSettings[i].length - 1];
                for (int k = 0; k < buttonsSettings[i].length; k++) {
                    if (k != j) {
                        adjacentButtons[pointer++] = buttonsSettings[i][k];
                    }
                }
                ((RetroImageButton) buttonsSettings[i][j]).setAdjacentButtons(adjacentButtons);
            }
            stage.addActor(buttonsSettings[i][j]);
        }
    }
    scaler = new Scaler(0, 1, .003f, true);
    colorScaler = new Color();
    xOffsetMax = 80;

    scrollbarMaximumY = viewport.getWorldHeight() - buttonClose.getHeight() + 1;
    scrollbarCurrentY = scrollbarMaximumY;

    inputMultiplexer = new InputMultiplexer();
    inputHandler = new TitleScreenInputProcessor(this, scrollbarMaximumY, 0);
    inputMultiplexer.addProcessor(inputHandler);
    inputMultiplexer.addProcessor(stage);
    scrollbarHandle = new RetroTextButton(shapeRenderer, 52, 25, font, "", new ClickListener() {

    });
    scrollbarHandle.setX(viewport.getWorldWidth() - scrollbarHandle.getWidth());
    scrollbarHandle.setThickness(3);
    stage.addActor(scrollbarHandle);
}

From source file:net.mwplay.cocostudio.ui.DemoScreen.java

License:Apache License

@Override
public void show() {
    super.show();
    stage = new Stage(new StretchViewport(DemoGame.GAME_WIDTH, DemoGame.GAME_HEIGHT));
    InputMultiplexer multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(stage);//w  w w.  java 2  s .  c o  m
    initDemoChange(multiplexer);
    Gdx.input.setInputProcessor(multiplexer);
    findAllDemos();
    defaultFont = Gdx.files.internal("share/MLFZS.TTF");
    changeDemo();
}

From source file:net.noviden.towerdefense.MapCreator.MapCreatorScreen.java

License:Open Source License

public MapCreatorScreen(final TowerDefense towerDefense) {
    this.towerDefense = towerDefense;

    camera = new OrthographicCamera();
    camera.setToOrtho(true, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.update();/*w  w w. ja va2  s.  c  om*/

    stage = new Stage();

    final Skin skin = new Skin(Gdx.files.internal("assets/uiskin.json"));

    table = new Table();
    table.setFillParent(true);

    name = UUID.randomUUID().toString().substring(0, 5);

    Label nameLabel = new Label("Name:", skin);
    final TextField nameField = new TextField(name, skin);
    TextButton addPathButton = new TextButton("Add New Path", skin);
    TextButton undoButton = new TextButton("Remove Last Point", skin);
    TextButton finishButton = new TextButton("Save Map", skin);
    TextButton exitButton = new TextButton("Exit", skin);

    final TextButton displayOptionsButton = new TextButton("Options", skin);

    // set up options table
    final Table optionsTable = new Table();
    optionsTable.setVisible(false);

    Label initialPlayerHealthLabel = new Label("Initial Player Health:", skin);
    final TextField initialPlayerHealthText = new TextField("" + MapSettings.DEFAULT_INITIAL_PLAYER_HEALTH,
            skin);
    Label initialPlayerResourcesLabel = new Label("Initial Player Resources:", skin);
    final TextField initialPlayerResourcesText = new TextField(
            "" + MapSettings.DEFAULT_INITIAL_PLAYER_RESOURCES, skin);
    Label initialUnitHealthLabel = new Label("Initial Unit Health:", skin);
    final TextField initialUnitHealthText = new TextField("" + MapSettings.DEFAULT_INITIAL_UNIT_HEALTH, skin);
    Label initialUnitMovementSpeedLabel = new Label("Initial Unit Movement Speed:", skin);
    final TextField initialUnitMovementSpeedText = new TextField("" + MapSettings.DEFAULT_INITIAL_UNIT_SPEED,
            skin);
    Label initialUnitDamageLabel = new Label("Initial Unit Damage:", skin);
    final TextField initialUnitDamageText = new TextField("" + MapSettings.DEFAULT_INITIAL_UNIT_DAMAGE, skin);
    Label defaultUnitSpawnRateLabel = new Label("Unit Spawn Rate:", skin);
    final TextField defaultUnitSpawnRateText = new TextField("" + MapSettings.DEFAULT_UNIT_SPAWN_RATE, skin);

    TextButton displayWavesCreatorButton = new TextButton("Waves Creator", skin);
    TextButton displayTurretsButton = new TextButton("Disable Turrets", skin);

    optionsTable.add(initialPlayerHealthLabel, initialPlayerHealthText);
    optionsTable.row();
    optionsTable.add(initialPlayerResourcesLabel, initialPlayerResourcesText);
    optionsTable.row();
    optionsTable.add(initialUnitHealthLabel, initialUnitHealthText);
    optionsTable.row();
    optionsTable.add(initialUnitMovementSpeedLabel, initialUnitMovementSpeedText);
    optionsTable.row();
    optionsTable.add(initialUnitDamageLabel, initialUnitDamageText);
    optionsTable.row();
    optionsTable.add(defaultUnitSpawnRateLabel, defaultUnitSpawnRateText);
    optionsTable.row();
    optionsTable.add(displayTurretsButton);

    final Table disableTurretsTable = new Table();
    disableTurretsTable.setVisible(false);

    final CheckBox disableChaingunTurretCheckbox = new CheckBox("Disable Chaingun", skin);
    final CheckBox disableBasicTurretCheckbox = new CheckBox("Disable Basic", skin);
    final CheckBox disableBuffTurretCheckbox = new CheckBox("Disable Buff", skin);
    final CheckBox disableHomingTurretCheckbox = new CheckBox("Disable Homing", skin);
    final CheckBox disableRocketTurretCheckbox = new CheckBox("Disable Rocket", skin);
    final CheckBox disableShotgunTurretCheckbox = new CheckBox("Disable Shotgun", skin);

    disableTurretsTable.add(disableChaingunTurretCheckbox);
    disableTurretsTable.row();
    disableTurretsTable.add(disableBasicTurretCheckbox);
    disableTurretsTable.row();
    disableTurretsTable.add(disableBuffTurretCheckbox);
    disableTurretsTable.row();
    disableTurretsTable.add(disableHomingTurretCheckbox);
    disableTurretsTable.row();
    disableTurretsTable.add(disableRocketTurretCheckbox);
    disableTurretsTable.row();
    disableTurretsTable.add(disableShotgunTurretCheckbox);

    optionsTable.row();
    optionsTable.add(disableTurretsTable);

    table.add(addPathButton);
    table.add(undoButton);
    table.add(finishButton);
    table.add(exitButton);
    table.row();
    table.add(nameLabel, nameField);
    table.add(displayOptionsButton);
    table.row();
    table.add(optionsTable);

    table.top();
    table.right();

    stage.addActor(table);

    inputMultiplexer = new InputMultiplexer();
    inputMultiplexer.addProcessor(stage);
    inputMultiplexer.addProcessor(new GestureDetector(new MyGestureListener()));

    Gdx.input.setInputProcessor(inputMultiplexer);

    addPathButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            // remove last point in set
            if (pointSet.size() > 1) {
                // valid to create a new path
                paths.push(new Path(pointSet, 5.0f));
                System.out.println("Added a path to paths Stack");
                pointSet = new ArrayList<Point>();
            } else {
                Dialog errorDialog = new Dialog("Error!", skin);
                errorDialog.text("Error! Must finish one path before starting another!");
                errorDialog.button("Ok");
                errorDialog.show(stage);
            }
        }
    });

    undoButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            // remove last point in set
            if (pointSet.size() > 0) {
                pointSet.remove(pointSet.size() - 1);
            } else {
                if (paths.size() > 0) {
                    Path path = paths.pop();
                    pointSet = (ArrayList<Point>) path.set.clone();
                    System.out.println("Popped from paths");
                }
            }
        }
    });

    exitButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            towerDefense.setScreen(new MapEditorSelectorScreen(towerDefense));
            dispose();
        }
    });

    finishButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {

            if (paths.size() == 0 && pointSet.size() < 2) {
                displayErrorMessage("Error! Each path must have at least an entrance and exit", skin);
                return;
            }

            // create settings for map
            int playerHealth = Integer.parseInt(initialPlayerHealthText.getText()),
                    playerResources = Integer.parseInt(initialPlayerResourcesText.getText()),
                    unitDamage = Integer.parseInt(initialUnitDamageText.getText());
            float unitHealth = Float.parseFloat(initialUnitHealthText.getText()),
                    unitSpeed = Float.parseFloat(initialUnitMovementSpeedText.getText()),
                    unitSpawnRate = Float.parseFloat(defaultUnitSpawnRateText.getText());

            // validation
            if (playerHealth <= 0.0f) {
                displayErrorMessage("Error! Player cannot start with 0.0 health", skin);
                return;
            } else if (unitHealth <= 0.0f) {
                displayErrorMessage("Error! Units cannot start with 0.0 health", skin);
                return;
            } else if (unitDamage <= 0.0f) {
                displayErrorMessage("Error! Units cannot start with 0.0 damage", skin);
                return;
            } else if (unitSpeed <= 0.0f) {
                displayErrorMessage("Error! Units cannot start with 0.0 speed", skin);
                return;
            } else if (unitSpawnRate <= 0.0f) {
                displayErrorMessage("Error! Spawn rate cannot be 0.0", skin);
                return;
            }

            ArrayList<BaseTurret.Type> disabledTypes = new ArrayList<BaseTurret.Type>();

            if (disableBasicTurretCheckbox.isChecked()) {
                disabledTypes.add(BaseTurret.Type.NORMAL);
            }
            if (disableBuffTurretCheckbox.isChecked()) {
                disabledTypes.add(BaseTurret.Type.BUFF);
            }
            if (disableChaingunTurretCheckbox.isChecked()) {
                disabledTypes.add(BaseTurret.Type.CHAINGUN);
            }
            if (disableHomingTurretCheckbox.isChecked()) {
                disabledTypes.add(BaseTurret.Type.HOMING);
            }
            if (disableRocketTurretCheckbox.isChecked()) {
                disabledTypes.add(BaseTurret.Type.ROCKET);
            }
            if (disableShotgunTurretCheckbox.isChecked()) {
                disabledTypes.add(BaseTurret.Type.SHOTGUN);
            }

            if (disabledTypes.size() == BaseTurret.Type.values().length) {
                displayErrorMessage("Error! Cannot disable all turrets", skin);
                return;
            }

            MapSettings mapSettings = new MapSettings();

            BaseTurret.Type[] disabledTypesArr = new BaseTurret.Type[disabledTypes.size()];
            disabledTypesArr = disabledTypes.toArray(disabledTypesArr);

            mapSettings.setDisabledTurretTypes(disabledTypesArr);

            String[] keys = { MapSettings.PLAYER_INITIAL_HEALTH_KEY, MapSettings.PLAYER_INITIAL_RESOURCES_KEY,
                    MapSettings.UNIT_INITIAL_DAMAGE_KEY, MapSettings.UNIT_INITIAL_HEALTH_KEY,
                    MapSettings.UNIT_INITIAL_SPEED_KEY, MapSettings.UNIT_SPAWN_RATE_KEY };

            float[] values = { playerHealth, playerResources, unitDamage, unitHealth, unitSpeed,
                    unitSpawnRate };

            mapSettings.putValues(keys, values);

            // make sure current pointSet is included in new map
            if (pointSet.size() > 1) {
                paths.push(new Path(pointSet, 5.0f));
            }

            // convert stack to array
            Path[] pathsForMap = new Path[paths.size()];
            int i = 0;
            while (!paths.empty()) {
                pathsForMap[i++] = paths.pop();
            }

            // finally create the map
            Map map = new Map(new Map.Dimensions(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()),
                    pathsForMap, nameField.getText(), mapSettings);

            towerDefense.maps.add(map);

            // return to main menu
            towerDefense.setScreen(new MapEditorSelectorScreen(towerDefense));
            dispose();
        }
    });

    displayOptionsButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (optionsTable.isVisible()) {
                optionsTable.setVisible(false);
                //                    disableTurretsTable.setVisible(false);
            } else {
                optionsTable.setVisible(true);
            }
        }
    });

    displayTurretsButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (disableTurretsTable.isVisible()) {
                disableTurretsTable.setVisible(false);
            } else {
                disableTurretsTable.setVisible(true);
            }
        }
    });

    pointSet = new ArrayList<Point>();
    paths = new Stack<Path>();

    batch = new SpriteBatch();
    shapeRenderer = new ShapeRenderer();
}

From source file:net.noviden.towerdefense.Screens.GameScreen.java

License:Open Source License

public GameScreen(final TowerDefense towerDefense, Map gameMap) {

    // store our callback to the Game class
    this.towerDefense = towerDefense;

    // initialize our input vector here, to save the precious gc
    vector3 = new Vector3();
    // get the initial mouse location, where we draw the next turret to be created
    mouseLocation = new Point(Gdx.input.getX(), Gdx.input.getY());

    // get the map from the arguments
    map = gameMap;/* www.j  a va 2s  .  c om*/

    // create a unit manager for each path on this map
    Path[] paths = map.getPaths();
    unitManagers = new UnitManager[paths.length];
    for (int i = 0; i < paths.length; i++) {
        unitManagers[i] = new UnitManager(paths[i], map.getSettings());
    }

    turretManager = new TurretManager();
    player = new Player(gameMap.getSettings());
    MissileManager.initialize();

    // set up the camera
    // FIXME there's something fishy with this and the screen size
    orthoCamera = new OrthographicCamera();
    //      orthoCamera.setToOrtho(true, TowerDefense.SCREEN_WIDTH, TowerDefense.SCREEN_HEIGHT);
    //      orthoCamera.position.set(TowerDefense.SCREEN_WIDTH / 2, TowerDefense.SCREEN_HEIGHT / 2, 0);
    orthoCamera.setToOrtho(true, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    orthoCamera.update();

    // set up the ui by creating the base Stage, where the resources table, upgrade table,
    //    information table and other fun takes place
    stage = new Stage();

    Skin skin = new Skin(Gdx.files.internal("assets/uiskin.json"));

    rootTable = new Table();
    rootTable.setFillParent(true);
    stage.addActor(rootTable);

    TextButton exitButton = new TextButton("Main Menu", skin);
    exitButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            towerDefense.setScreen(new MainMenuScreen(towerDefense));
        }
    });

    pauseButton = new TextButton("Pause", skin);
    pauseButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            pauseGame();
        }
    });

    Table selectTypeTable = new Table();

    final TextButton buttonSelectBasicTurret = new TextButton("Basic (R50)", skin, "default");
    final TextButton buttonSelectChaingunTurret = new TextButton("Chaingun (R50)", skin);
    final TextButton buttonSelectShotgunTurret = new TextButton("Shotgun (R50)", skin);
    final TextButton buttonSelectRocketTurret = new TextButton("Rocket (R50)", skin);
    final TextButton buttonSelectHomingTurret = new TextButton("Homing (R50)", skin);
    final TextButton buttonSelectBuffTurret = new TextButton("Buff (R50)", skin);

    selectTurretButtons = new TextButton[] { buttonSelectBasicTurret, buttonSelectChaingunTurret,
            buttonSelectShotgunTurret, buttonSelectRocketTurret, buttonSelectHomingTurret,
            buttonSelectBuffTurret };

    if (!map.getSettings().isTurretTypeDisabled(BaseTurret.Type.NORMAL))
        selectTypeTable.add(buttonSelectBasicTurret);
    if (!map.getSettings().isTurretTypeDisabled(BaseTurret.Type.CHAINGUN))
        selectTypeTable.add(buttonSelectChaingunTurret);

    if (!map.getSettings().isTurretTypeDisabled(BaseTurret.Type.ROCKET))
        selectTypeTable.add(buttonSelectRocketTurret);
    if (!map.getSettings().isTurretTypeDisabled(BaseTurret.Type.SHOTGUN))
        selectTypeTable.add(buttonSelectShotgunTurret);

    if (!map.getSettings().isTurretTypeDisabled(BaseTurret.Type.HOMING))
        selectTypeTable.add(buttonSelectHomingTurret);
    if (!map.getSettings().isTurretTypeDisabled(BaseTurret.Type.BUFF))
        selectTypeTable.add(buttonSelectBuffTurret);

    buttonSelectBasicTurret.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            player.setTurretSelectedForPurchase(new BasicTurret(mouseLocation.clone()));
            resetVisualTurretSelection();
            buttonSelectBasicTurret.setColor(Color.NAVY);
        }
    });

    buttonSelectChaingunTurret.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            player.setTurretSelectedForPurchase(new ChaingunTurret(mouseLocation.clone()));
            resetVisualTurretSelection();
            buttonSelectChaingunTurret.setColor(Color.NAVY);
        }
    });

    buttonSelectRocketTurret.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            player.setTurretSelectedForPurchase(new RocketTurret(mouseLocation.clone()));
            resetVisualTurretSelection();
            buttonSelectRocketTurret.setColor(Color.NAVY);
        }
    });

    buttonSelectShotgunTurret.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            player.setTurretSelectedForPurchase(new ShotgunTurret(mouseLocation.clone()));
            resetVisualTurretSelection();
            buttonSelectShotgunTurret.setColor(Color.NAVY);
        }
    });

    buttonSelectHomingTurret.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            player.setTurretSelectedForPurchase(new HomingTurret(mouseLocation.clone()));
            resetVisualTurretSelection();
            buttonSelectHomingTurret.setColor(Color.NAVY);
        }
    });

    buttonSelectBuffTurret.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            player.setTurretSelectedForPurchase(new BuffTurret(mouseLocation.clone(), turretManager));
            resetVisualTurretSelection();
            buttonSelectBuffTurret.setColor(Color.NAVY);
        }
    });

    resetVisualTurretSelection();

    // add in information view
    Table infoTable = new Table();

    resourcesLabel = new Label("Resources: R" + player.getResources(), skin);
    scoreLabel = new Label("Score: " + player.getScore(), skin);
    healthLabel = new Label("Health: " + player.getHealth(), skin);
    numTurretsLabel = new Label("Turrets Created: " + player.getNumTurretsCreated(), skin);
    numUnitsKilledLabel = new Label("Units killed: " + player.getNumUnitsKilled(), skin);

    startDate = new Date();
    timeLabel = new Label("Elapsed: ", skin);

    infoTable.add(healthLabel).pad(5.0f);
    infoTable.add(scoreLabel).pad(5.0f);
    infoTable.add(resourcesLabel).pad(5.0f);
    infoTable.add(numTurretsLabel).pad(5.0f);
    infoTable.add(numUnitsKilledLabel).pad(5.0f);
    infoTable.add(timeLabel).pad(10.0f);

    // turret upgrade user interface
    upgradeTable = new Table();

    selectedTurretLabel = new Label("Upgrade Turret", skin);
    damageLabel = new Label("Damage (Current)", skin);
    upgradeDamageButton = new TextButton("+10 (R40)", skin);
    rangeLabel = new Label("Range (Current)", skin);
    upgradeRangeButton = new TextButton("+10 (R40)", skin);
    uniqueModifierLabel = new Label("Unique (Current)", skin);
    upgradeUniqueModifierButton = new TextButton("+1 (R40)", skin);

    sellButton = new TextButton("Sell (Value)", skin);

    upgradeTable.add(selectedTurretLabel);
    upgradeTable.add(sellButton);
    upgradeTable.row();
    upgradeTable.add(damageLabel);
    upgradeTable.add(upgradeDamageButton);
    upgradeTable.row();
    upgradeTable.add(rangeLabel);
    upgradeTable.add(upgradeRangeButton);
    upgradeTable.row();
    upgradeTable.add(uniqueModifierLabel);
    upgradeTable.add(upgradeUniqueModifierButton);

    upgradeTable.setVisible(false);

    Table menuTable = new Table();
    menuTable.add(pauseButton, exitButton);

    fpsLabel = new Label("0fps", skin);

    Table topHalfTable = new Table(), botHalfTable = new Table();
    //      topHalfTable.setDebug(true); botHalfTable.setDebug(true);

    topHalfTable.add(infoTable);
    topHalfTable.row();
    topHalfTable.add(selectTypeTable);
    topHalfTable.row();
    topHalfTable.add(upgradeTable).expandX().right();

    botHalfTable.add(fpsLabel).expandX().left().expandY().bottom();
    botHalfTable.add(menuTable).expandX().right().expandY().bottom();

    rootTable.add(topHalfTable).fill().top();
    rootTable.row();
    rootTable.add(botHalfTable).fill().expand();

    /*** END OF TABLES AND ALIGNMENT ***/

    upgradeDamageButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            BaseTurret turret = player.getTurretSelectedForUpgrade();
            if (player.getResources() >= turret.getUpgradeCost() && turret.canUpgradeDamage()) {
                player.decreaseResources(turret.getUpgradeCost());
                turret.upgradeDamage();
            }
        }
    });

    upgradeRangeButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            BaseTurret turret = player.getTurretSelectedForUpgrade();
            if (player.getResources() >= turret.getUpgradeCost()) {
                player.decreaseResources(turret.getUpgradeCost());
                player.getTurretSelectedForUpgrade().upgradeRange();
            }
        }
    });

    upgradeUniqueModifierButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            BaseTurret turret = player.getTurretSelectedForUpgrade();
            if (player.getResources() >= turret.getUpgradeCost() && turret.canUpgradeUniqueModifier()) {
                player.decreaseResources(turret.getUpgradeCost());
                turret.upgradeUniqueModifier();
            }
        }
    });

    sellButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            player.addResources(player.getTurretSelectedForUpgrade().getWorth());
            turretManager.removeTurret(player.getTurretSelectedForUpgrade());
            player.setState(Player.State.TURRET_PLACE);
            upgradeTable.setVisible(false);
        }
    });

    // set up gameOver menu, which includes its own stage for alignment purposes
    gameOverTable = new Table();
    gameOverTable.setFillParent(true);
    gameOverTable.setVisible(false);

    highScoreLabel = new Label("High Score: ", skin);
    lastScoreLabel = new Label("Last Score: ", skin);
    continueButton = new TextButton("Continue", skin);

    gameOverTable.add(highScoreLabel);
    gameOverTable.row();
    gameOverTable.add(lastScoreLabel);
    gameOverTable.row();
    gameOverTable.add(continueButton);

    gameOverTable.center();

    gameOverStage = new Stage();
    gameOverStage.addActor(gameOverTable);

    continueButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            towerDefense.setScreen(new MainMenuScreen(towerDefense));
            dispose();
        }
    });

    // now set input processing, by adding all input sources to the inputMultiplexer
    inputMultiplexer = new InputMultiplexer();

    inputMultiplexer.addProcessor(gameOverStage);
    inputMultiplexer.addProcessor(stage);
    inputMultiplexer.addProcessor(new GestureDetector(new MyGestureListener()));
    inputMultiplexer.addProcessor(new MyInputProcessor());

    Gdx.input.setInputProcessor(inputMultiplexer);

    // instantiate the spritebatch, where all drawing takes place, and shapeRenderer likewise
    batch = new SpriteBatch();
    shapeRenderer = new ShapeRenderer();

    // game starts off going fast!
    isPaused = false;

    // instantiate transformation
    _transformation = new TurretTransformation(turretManager);

    // instantiate the fpsLogger
    fpsLogger = new FPSLogger();
}

From source file:net.onedaybeard.keyflection.demo.DemoUI.java

License:Apache License

@Override
public void create() {
    background = new Color(0.2f, 0.2f, 0.2f, 1f);

    texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    font = new BitmapFont(Gdx.files.internal("data/font.fnt"), false);

    stageActions = new StageKeys();

    stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);

    float loc = (NUM_SPRITES * (32 + SPACING) - SPACING) / 2;
    for (int i = 0; i < NUM_GROUPS; i++) {
        Group group = new Group();
        group.setX((float) Math.random() * (stage.getWidth() - NUM_SPRITES * (32 + SPACING)));
        group.setY((float) Math.random() * (stage.getHeight() - NUM_SPRITES * (32 + SPACING)));
        group.setOrigin(loc, loc);//from   w w w.ja  v a2s .  c o  m

        fillGroup(group, texture);
        stage.addActor(group);
    }

    uiTexture = new Texture(Gdx.files.internal("data/ui.png"));
    uiTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    ui = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
    ui.addListener(new KeyflectionInputListener(stageActions));

    Image blend = new Image(new TextureRegion(uiTexture, 0, 0, 64, 32));
    blend.setAlign(Align.center);
    blend.setScaling(Scaling.none);
    blend.addListener(new InputListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            stageActions.toggleBlending();
            return true;
        }
    });
    blend.setY(ui.getHeight() - 64);

    Image rotate = new Image(new TextureRegion(uiTexture, 64, 0, 64, 32));
    rotate.setAlign(Align.center);
    rotate.setScaling(Scaling.none);
    rotate.addListener(new InputListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            stageActions.toggleRotation();
            return true;
        }
    });
    rotate.setPosition(64, blend.getY());

    Image scale = new Image(new TextureRegion(uiTexture, 64, 32, 64, 32));
    scale.setAlign(Align.center);
    scale.setScaling(Scaling.none);
    scale.addListener(new InputListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            stageActions.toggleScaling();
            return true;
        }
    });
    scale.setPosition(128, blend.getY());

    ui.addActor(blend);
    ui.addActor(rotate);
    ui.addActor(scale);

    hint = new Label("Press F1 to see keyboard shortcuts.", new Label.LabelStyle(font, Color.WHITE));
    hint.setPosition(10, 45);
    hint.setColor(0, 1, 0, 1);
    ui.addActor(hint);

    fps = new Label("fps: 0", new Label.LabelStyle(font, Color.WHITE));
    fps.setPosition(10, 30);
    fps.setColor(0, 1, 0, 1);
    ui.addActor(fps);

    renderer = new ShapeRenderer();

    InputMultiplexer multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(new KeyflectionInputProcessor(new GlobalKeys()));
    multiplexer.addProcessor(stage);
    multiplexer.addProcessor(ui);

    Gdx.input.setInputProcessor(multiplexer);
}

From source file:org.ah.gcc.rover.AndroidGCCRoverController.java

License:Open Source License

@Override
public void create() {
    // platformSpecific.init();

    font = new BitmapFont(Gdx.files.internal("fonts/din-alternate-bold-64.fnt"), true);
    glyphLayout = new GlyphLayout();

    font.setColor(Color.BLACK);/* w  w w.  j ava2  s .c  o  m*/
    batch = new SpriteBatch();
    img = new Texture("badlogic.jpg");

    camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    cellSize = Gdx.graphics.getWidth() / 20;

    shapeRenderer = new ShapeRenderer();

    leftjoystick = new JoyStick((int) cellSize * 8, (int) cellSize * 4, (int) cellSize * 4);
    rightjoystick = new JoyStick((int) cellSize * 8, (int) cellSize * 16, (int) cellSize * 4);

    leftExpo = new ExpoGraph((int) cellSize * 5, (int) cellSize * 2, (int) cellSize * 2, (int) cellSize * 2);
    rightExpo = new ExpoGraph((int) cellSize * 13, (int) cellSize * 2, (int) cellSize * 2, (int) cellSize * 2);

    leftExpo.setPercentage(0.75f);
    rightExpo.setPercentage(0.90f);

    roverSelectButton = new Button((int) cellSize * 6, 0, (int) cellSize * 8, (int) (cellSize * 1.5),
            new Button.ButtonCallback() {
                @Override
                public void invoke(boolean state) {
                    if (state) {
                        newSelectedRover = selectedRover + 1;
                        if (newSelectedRover >= ROVERS.length) {
                            newSelectedRover = 0;
                        }
                    }
                }
            });

    pov = new POV((int) cellSize * 9, (int) cellSize * 4, (int) cellSize * 2);

    button1 = new RoundButton((int) cellSize * 6, (int) cellSize * 11, (int) cellSize / 2);

    switchLT = new SquareButton((int) cellSize * 0, (int) (cellSize * 0), (int) cellSize * 4,
            (int) cellSize * 2);
    switchLT.setState(false);
    switchLB = new Switch((int) cellSize * 0, (int) (cellSize * 2), (int) cellSize * 2, Orientation.HORIZONTAL);
    switchLB.setState(false);

    switchRT = new SquareButton((int) cellSize * 16, (int) (cellSize * 0), (int) cellSize * 4,
            (int) cellSize * 2);
    switchRT.setState(false);
    switchRB = new Switch((int) cellSize * 16, (int) (cellSize * 2), (int) cellSize * 2,
            Orientation.HORIZONTAL);
    switchRB.setState(false);

    inputMultiplexer = new InputMultiplexer();
    inputMultiplexer.addProcessor(this);
    inputMultiplexer.addProcessor(new GestureDetector(this));
    Gdx.input.setInputProcessor(inputMultiplexer);
    screenController = new ScreenController();
    screenController.setLeftJotstick(leftjoystick);
    screenController.setRightJotstick(rightjoystick);

    screenController.setButton(switchLB, ControllerState.ButtonType.ORBIT_BUTTON);
    roverDriver = new RoverDriver(roverControl, screenController);

    logoDrawer = new LogoDrawer(batch, camera);

}