Java Code Examples for com.badlogic.gdx.scenes.scene2d.Stage

The following are top voted examples for showing how to use com.badlogic.gdx.scenes.scene2d.Stage. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Race99   File: StageFactory.java   Source Code and License 7 votes vote down vote up
public Stage createLoadingStage(){
    Stage stage = createStage();
    stage.setViewport(viewport);
    stage.addActor(new GameObjectBodyless(new Texture("default_background.png")));
    GameObjectBodyless gameObjectBodyless = new GameObjectBodyless(new Texture("loading_screen_part1.png")){
        @Override
        public void act(float delta) {
            super.act(delta);
            getSprite().setOriginCenter();
            getSprite().rotate(3);
        }
    };
    gameObjectBodyless.setPosition(viewport.getScreenWidth() - gameObjectBodyless.getSprite().getWidth(),
            viewport.getScreenHeight() - gameObjectBodyless.getSprite().getHeight());
    stage.addActor(gameObjectBodyless);
    return stage;
}
 
Example 2
Project: DarkDay   File: Hud.java   Source Code and License 6 votes vote down vote up
public Hud(SpriteBatch sb) {
    countKill = 0;
    viewport = new FitViewport(ScreenConf.V_WIDTH, ScreenConf.V_HEIGHT, new OrthographicCamera());

    stage = new Stage(viewport, sb);

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

    countKillLabel = new Label(String.format("%03d", countKill), new Label.LabelStyle(new BitmapFont(), Color.WHITE));

    table.add(countKillLabel).expandX().padTop(10);
    table.add().expandX();
    table.add().expandX();
    table.add().expandX();
    stage.addActor(table);

}
 
Example 3
Project: Catan   File: KnightActor.java   Source Code and License 6 votes vote down vote up
public KnightActionsWindow displayActions(Stage stage) {
    if (stage != null) {
        // Create the window if it's not created
        if (actionWindow == null)
            actionWindow = new KnightActionsWindow(this);

        actionWindow.setPosition(getX() + getWidth(), getTop());

        // Add the window if not already added
        if (!actionWindow.hasParent())
            stage.addActor(actionWindow);

        return actionWindow;
    }
    return null;
}
 
Example 4
Project: feup-lpoo-armadillo   File: MenuScreen.java   Source Code and License 6 votes vote down vote up
/**
 * Menu Screen's constructor.
 * It initializes all the Menu elements.
 *
 * @param game The current game session.
 */
protected MenuScreen(final Armadillo game) {
    this.game = game;
    batch = game.getBatch();
    gameServices = game.getGameServices();
    skin1 = game.getPrimarySkin();
    skin2 = game.getSecondarySkin();

    viewport = new FitViewport(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
    viewport.apply();

    stage = new Stage(viewport, batch);

    backgroundImg = new Image(game.getAssetManager().get("background.png", Texture.class));
    backgroundImg.setScale(VIEWPORT_WIDTH / backgroundImg.getWidth(), VIEWPORT_HEIGHT / backgroundImg.getHeight());

    titleImg = new Image(game.getAssetManager().get("armadillo_title.png", Texture.class));
    titleImg.setSize(0.8f * titleImg.getWidth(), 0.8f * titleImg.getHeight());
    titleImg.setPosition(VIEWPORT_WIDTH / 2 - titleImg.getWidth() / 2, VIEWPORT_HEIGHT * 0.98f - titleImg.getHeight());
}
 
Example 5
Project: NoRiskNoFun   File: NoRiskNoFunDrawFigures.java   Source Code and License 6 votes vote down vote up
@Override
public void create () {
    camera = new OrthographicCamera();
    camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    stage = new Stage();
    stage.addListener(new InputListener(){
        @Override
        public boolean touchDown (InputEvent event, float x, float y, int pointer, int button){

            stage.getActors().get(counter).addAction(Actions.moveTo(x-50,y-50,1));
            counter++;
            if(counter==stage.getActors().size) {
                counter=0;
            }
            return true;
        }
    });
    Gdx.input.setInputProcessor(stage);
}
 
Example 6
Project: Cubes   File: CraftingInventoryActor.java   Source Code and License 6 votes vote down vote up
@Override
protected void setStage(Stage stage) {
  if (stage == null) {
    for (int i = 0; i < 9; i++) {
      if (c.itemStacks[i] != null)
        InventoryHelper.addItemstack(Cubes.getClient().player.getInventory(), c.itemStacks[i]);
    }
  }
  super.setStage(stage);
}
 
Example 7
Project: conquest   File: MainMenu.java   Source Code and License 6 votes vote down vote up
@Override
public void show() {
    player = new Player(Assets.random());
    client = new Client(player);

    stage = new Stage();

    Image logo = new Image(Assets.LOGO);
    logo.setPosition((Gdx.graphics.getWidth() - logo.getWidth()) / 2, Gdx.graphics.getHeight() * 0.85f);
    Image shadow = dropShadow(logo);

    stage.addActor(logo);
    stage.addActor(shadow);
    stage.addActor(new PlayGroup(client));

    stage.getRoot().addCaptureListener(new InputListener() {
        public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
            if (!(event.getTarget() instanceof TextField)) stage.setKeyboardFocus(null);
            return true;
        }
    });

    Gdx.input.setInputProcessor(stage);
}
 
Example 8
Project: projecttd   File: HudScene.java   Source Code and License 6 votes vote down vote up
public HudScene(SpriteBatch batch, ShapeRenderer shapeRenderer, ArcRenderer arcRenderer) {
    this.batch = batch;
    stage = new Stage();

    VisUI.load();

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

    scoreLabel = new Label("", new Label.LabelStyle(new BitmapFont(), Color.VIOLET));
    setScore(score);
    balanceLabel = new Label("", new Label.LabelStyle(new BitmapFont(), Color.VIOLET));
    setBalance(balance);

    table.add(scoreLabel).align(Align.left).expandX();
    table.add(balanceLabel).align(Align.right).expandX();

    stage.addActor(table);


    ringButton = new RingButton(shapeRenderer, arcRenderer);
    ringButton.setBounds(10, 10, 100, 100);
    stage.addActor(ringButton);
}
 
Example 9
Project: bobbybird   File: LoadingState.java   Source Code and License 6 votes vote down vote up
@Override
public void start() {
    finishedLoading = false;
    
    stage = new Stage(new ScreenViewport());
    
    skin = createSkin();
    
    Image image= new Image(skin, "bg");
    image.setScaling(Scaling.stretch);
    image.setFillParent(true);
    stage.addActor(image);
    
    root = new Table();
    root.setFillParent(true);
    stage.addActor(root);
    
    progressBar = new ProgressBar(0, 1, .01f, false, skin);
    progressBar.setAnimateDuration(.1f);
    root.add(progressBar).growX().expandY().pad(20.0f);
}
 
Example 10
Project: FlappySpinner   File: MenuScreen.java   Source Code and License 6 votes vote down vote up
public MenuScreen(Game game) {
    Box2D.init();
    this.game = game;
    world = new World(new Vector2(0, 0), false);
    stage = new Stage(new StretchViewport(Constants.WIDTH, Constants.HEIGHT));

    preferences = new GamePreferences();
    audioManager = AudioManager.getInstance();
    Gdx.input.setInputProcessor(stage);

    FlappySpinner.gameManager.changeBackgroundColor("#4ec0ca");

    setUpBackground();
    setUpButtons();
    setUpLogo();
}
 
Example 11
Project: summer17-android   File: MenuState.java   Source Code and License 6 votes vote down vote up
public void create() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    //font = new BitmapFont();
    //skin = new Skin();
    //buttonAtlas = new TextureAtlas(Gdx.files.internal());
    //skin.addRegions(buttonAtlas);

    button = new Button();
    button.setStyle(new Button.ButtonStyle());

    button.addCaptureListener(new EventListener() {
        @Override
        public boolean handle(Event event) {
            Gdx.app.log("LOG", "event " + event);
            return false;
        }
    });
    stage.addActor(button);
}
 
Example 12
Project: arcadelegends-gg   File: InputSettingsScreen.java   Source Code and License 6 votes vote down vote up
/**
 * Method responsible for initializing the main menu
 * Called when the screen becomes the current screen of the game
 */
@Override
public void show() {
    cam = new OrthographicCamera();
    viewport = new FitViewport(1920, 1080);
    viewport.setCamera(cam);
    stage = new Stage(viewport);
    stage.setViewport(viewport);
    skin = settingsAssets.styles_json;
    int x = 1920;
    int y = 1080;
    spriteBatch = new SpriteBatch();
    mainbackground = settingsAssets.testmainscreen;
    BitmapFont font = settingsAssets.bocklin_fnt;
    TextureRegion backgroundTexture = new TextureRegion(settingsAssets.background_textbutton);

    inputTable = new Table();
    keys = IInputConfig.InputKeys.values();
    keyMap = new HashMap<>();

    initInputRows(font, backgroundTexture);
    createBackButton();
    AL.input.setInputProcessor(new InputMultiplexer(stage, this));
}
 
Example 13
Project: enklave   File: ScreenExtensions.java   Source Code and License 6 votes vote down vote up
@Override
public void show() {
    if(drawone){
        addBackgroundExtension();
        addPuls();
        addimagebg();
        addButtonBottom();
        drawone = false;
    }
    cameraGroupStrategy = new CameraGroupStrategy(camera);
    batch = new DecalBatch(cameraGroupStrategy);
    stage = new Stage(new StretchViewport(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()));
    addtostage();
    Gdx.input.setCatchBackKey(true);
    inputmulti = new InputMultiplexer();
    inputmulti.addProcessor(stage);
    Gdx.input.setInputProcessor(inputmulti);
}
 
Example 14
Project: enklave   File: ScreenRooms.java   Source Code and License 6 votes vote down vote up
@Override
    public void show() {
        if(drawone){
            addroomselect();
            addButtonBottom();
            addPuls();
            addimagebg();
            addbuildRoom();
            addtimerbuildroom();
            drawone = false;
        }
        cameraGroupStrategy = new CameraGroupStrategy(camera);
//        CameraInputController controller = new CameraInputController(camera);
        stage = new Stage(new StretchViewport(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()));
        batchsprite = new SpriteBatch();
        addtostage();
        batch = new DecalBatch(this.cameraGroupStrategy);
        Gdx.input.setCatchBackKey(true);
        InputMultiplexer inputmulti = new InputMultiplexer();
        inputmulti.addProcessor(stage);
        Gdx.input.setInputProcessor(inputmulti);
    }
 
Example 15
Project: enklave   File: ScreenDescribeEnklave.java   Source Code and License 6 votes vote down vote up
@Override
public void show() {
    if(drawone){
        addActiveRooms();
        createBuildRoom();
        createAddExtensionGroup();
        addDescribeEnklave();
        drawone = false;
    }
    backButton.setChecked(false);
    Gdx.input.setCatchBackKey(true);
    stage = new Stage(new StretchViewport(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()));
    addtoStage(stage);
    stage.addActor(backButton);
    Gdx.input.setInputProcessor(stage);
}
 
Example 16
Project: enklave   File: ScreenSetting.java   Source Code and License 6 votes vote down vote up
@Override
public void show() {
    stage = new Stage(new StretchViewport(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()));
    if(drawone) {
        initializeMenuTab();
        manager.loadAssetsSettings();
        manager.getAssetsSettings().finish();
        addSettingTutorial();
        addSettingPresentation();
        addChangeFaction();
        addKeepScreenOn();
        addTestCombat();
        drawone = false;
    }
    addtoStage();
    checkButtons();
    b5.setChecked(true);
    sp.setScrollPercentX(100);
    sp.updateVisualScroll();
    backButton.setChecked(false);
    Gdx.input.setCatchBackKey(true);
    Gdx.input.setInputProcessor(stage);
}
 
Example 17
Project: gdx-controllerutils   File: ControllerMenuDialog.java   Source Code and License 6 votes vote down vote up
@Override
public Dialog show(Stage stage, Action action) {
    previousFocussedActor = null;
    previousEscapeActor = null;

    super.show(stage, action);

    if (stage instanceof ControllerMenuStage) {
        previousFocussedActor = ((ControllerMenuStage) stage).getFocussedActor();
        previousEscapeActor = ((ControllerMenuStage) stage).getEscapeActor();

        if (buttonsToAdd.size >= 1)
            ((ControllerMenuStage) stage).setFocussedActor(buttonsToAdd.get(0));

        if (buttonsToAdd.size == 1)
            ((ControllerMenuStage) stage).setEscapeActor(buttonsToAdd.get(0));
    }

    return this;

}
 
Example 18
Project: Polymorph   File: GameScreen.java   Source Code and License 6 votes vote down vote up
private void initHud() {
    hud = new Stage(viewport, batch);
    Gdx.input.setInputProcessor(new InputMultiplexer(new KeyboardInputHandler(), hud));

    //init widgets
    ColorButton[] colorButtons = createColorButtons();
    final ShapeButton[] shapeButtons = createShapeButtons(colorButtons);

    // add widgets to stage
    for (ShapeButton shapeButton : shapeButtons) {
        hud.addActor(shapeButton);
    }
    for (ColorButton colorButton : colorButtons) {
        hud.addActor(colorButton);
    }

    TextureAtlas textureAtlas = polymorph.getAssetManager().get(Polymorph.MASTER_PATH, TextureAtlas.class);
    hud.addActor(createHealthBar(textureAtlas));
    hud.addActor(createPauseButton(textureAtlas));
}
 
Example 19
Project: MMORPG_Prototype   File: QuestBoardDialog.java   Source Code and License 6 votes vote down vote up
public QuestBoardDialog(ActorManipulator linkedContainer, long id, QuestDataPacket[] quests,
		Stage containerForPopUpDialog, PacketsSender packetsSender)
{
	super("Quests", linkedContainer, id);

	for(QuestDataPacket quest : quests)
	{
	    QuestPosition questPosition = new QuestPosition(quest.getName(), quest.getDescription(), containerForPopUpDialog, packetsSender);
	    questPositions.put(quest.getName(), questPosition);
	    getContentTable().add(questPosition);
	    getContentTable().row();
	}
	if(questPositions.isEmpty())
           addNoQuestsAvailableLabel();

	this.pack();
}
 
Example 20
Project: GangsterSquirrel   File: MenuScreen.java   Source Code and License 6 votes vote down vote up
public MenuScreen(MainGameClass game) {
    this.game = game;

    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);

    skin = new Skin(Gdx.files.internal("skins/Flat_Earth_UI_Skin/flatearthui/flat-earth-ui.json"));

    progressBarStyle = skin.get("fancy", ProgressBar.ProgressBarStyle.class);
    TiledDrawable tiledDrawable = skin.getTiledDrawable("slider-fancy-knob").tint(skin.getColor("selection"));
    tiledDrawable.setMinWidth(0);
    progressBarStyle.knobBefore = tiledDrawable;

    sliderStyle = skin.get("fancy", Slider.SliderStyle.class);
    sliderStyle.knobBefore = tiledDrawable;

    layoutTable = new Table();
    layoutTable.top();
    layoutTable.setFillParent(true);
    layoutTable.pad(getPixelSizeFromDensityIndependentPixels(50));
}
 
Example 21
Project: ProjektGG   File: BaseUIScreen.java   Source Code and License 5 votes vote down vote up
@Override
public void show() {
	stage = new Stage(new ScreenViewport());
	mainTable = new Table();
	stage.addActor(mainTable);
	mainTable.setFillParent(true);

	mainTable.setDebug((boolean) game.showDebugStuff());

	game.setInputProcessor(stage);

	initUI();
}
 
Example 22
Project: cocos2d-java   File: GdxUIConsole.java   Source Code and License 5 votes vote down vote up
@Override
protected boolean onUpdate(float dt) {
	Stage stage = input.getStage();
	if(stage != null) {
		stage.setKeyboardFocus(input);
	}
	flushOutput();
	return true;
}
 
Example 23
Project: bobbybird   File: MenuState.java   Source Code and License 5 votes vote down vote up
@Override
public void start() {
    skin = getCore().getAssetManager().get(Core.DATA_PATH + "/skin/skin.json", Skin.class);
    stage = new Stage(new ScreenViewport());
    
    Gdx.input.setInputProcessor(stage);
    
    Image bg = new Image(skin, "sky");
    bg.setFillParent(true);
    stage.addActor(bg);
    
    createBG();
    
    createMenu();
}
 
Example 24
Project: libgdx_ui_editor   File: MainPanel.java   Source Code and License 5 votes vote down vote up
public void setListeners(Stage stage) {
    stage.addListener(new InputListener() {
        @Override
        public boolean scrolled(InputEvent event, float x, float y, int amount) {
            if (editingZone != null) editingZone.zoomBy(amount);
            return false;
        }
    });
}
 
Example 25
Project: Race99   File: StageFactory.java   Source Code and License 5 votes vote down vote up
public Stage createStartStage(){
    Stage stage = createStage();
    stage.setViewport(viewport);
    stage.addActor(new GameObjectBodyless(new Texture("splash_screen1.png")){

        private int i = 100;
        private int counter = 0;

        @Override
        public void act(float delta) {
            super.act(delta);
            if (i < 0){
                i = 100;
                counter++;
                if (counter == 2){
                    remove();
                    setChanged();
                    notifyObservers("StartStageEnd");
                }
                setTexture(new Texture("splash_screen2.png"));
                setSprite(new Sprite(getTexture()));
            } else if (i >= 0) {
                i--;
            }
        }
    });
    return stage;
}
 
Example 26
Project: gdx-splash   File: LockWindow.java   Source Code and License 5 votes vote down vote up
private void setupUI() {
    stage = new Stage();
    VisTable root = new VisTable();
    stage.addActor(root);
    root.setFillParent(true);
    root.align(Align.center);

    VisLabel label = new VisLabel("It appears you have already opened an instance of this app.\n\n" +
            "To ensure data integrity this is not possible. If you are sure that no open app " +
            "instance exists delete the lock file ~/.gdxsplash/.lock and restart GdxSplash.");
    label.setAlignment(Align.center);
    label.setWrap(true);
    root.add(label).pad(10).grow().row();
}
 
Example 27
Project: FlappySpinner   File: GameScreen.java   Source Code and License 5 votes vote down vote up
public GameScreen(Game game, int score, boolean isRelife) {
    Box2D.init();

    SCORE = score;
    this.isRelife = isRelife;

    preferences = new GamePreferences();
    audioManager = AudioManager.getInstance();

    aGame = game;
    stage = new Stage(new StretchViewport(Constants.WIDTH, Constants.HEIGHT));
    world = WorldUtils.createWorld();
    world.setContactListener(this);

    FlappySpinner.gameManager.changeBackgroundColor("#e9fcd9");

    Gdx.input.setInputProcessor(stage);

    state = GameState.RESUME;

    setUpBackground();
    setUpTube();
    setUpSpinner();
    setUpGround();

    setUpOnPause();
    setUpOnResume();
    setUpOnFinish();

    setUpButtons();
    setUpLabels();
}
 
Example 28
Project: Planet-Generator   File: GameUI.java   Source Code and License 5 votes vote down vote up
public GameUI(PlanetGeneratorGame game) {
    this.game = game;
    this.scene = game.getScene();
    stage = new Stage();

    initialize();
}
 
Example 29
Project: Catan   File: KnightActionsWindow.java   Source Code and License 5 votes vote down vote up
@Override
protected void setStage(Stage stage) {
    super.setStage(stage);
    // Every time this window is displayed, do these checks...
    Knight knight = knightActor.getKnight();
    promoteButton.setDisabled(knight.is(MIGHTY) || knight.isPromotedThisTurn());
    activateButton.setDisabled(knight.isActive() || knight.isActivatedThisTurn());
    moveButton.setDisabled(!knight.isActive() || knight.isActivatedThisTurn());
}
 
Example 30
Project: Catan   File: SignUpScreen.java   Source Code and License 5 votes vote down vote up
@Override
public void show() {
    bg = new Texture("BG.png");
    bg.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    stage = new Stage();
    Gdx.input.setInputProcessor(stage);

    if (skin == null)
        createBasicSkin();

    // Create & add the window
    CatanWindow window = new CatanWindow(TITLE, skin);
    stage.addActor(window);

    Label usernameLabel = new Label ("Username:", skin);
    TextField usernameText = new TextField ("", skin);
    Label passwordLabel = new Label ("Password:", skin);
    TextField passwordText = new TextField("", skin);

    /*//Create table
    Table mainTable = new Table();
    //add labels to table
    mainTable.add(usernameLabel);
    mainTable.add(usernameText).width(200);
    mainTable.row();
    mainTable.add(passwordLabel);
    mainTable.add(passwordText).width(200);

    mainTable.setFillParent(true);
    stage.addActor(mainTable);*/
}
 
Example 31
Project: NoRiskNoFun   File: SceneBase.java   Source Code and License 5 votes vote down vote up
/**
 * Constructor taking scene name and color used to clear background.
 * @param sceneName Scene's name.
 * @param clearColor Color used to clear background.
 */
protected SceneBase(String sceneName, Color clearColor) {

    this.sceneName = sceneName;
    this.clearColor = clearColor;
    sceneObjects = new LinkedList<>();
    stage = new Stage();
}
 
Example 32
Project: skycity   File: Chat.java   Source Code and License 5 votes vote down vote up
public Chat(SpriteBatch batch){
    field = new TextField("", Assets.getInstance().getSkin());
    field.setVisible(false);

    table = new Table();
    table.bottom().padLeft(20).padRight(20).padBottom(10).setFillParent(true);
    table.setDebug(false);
    table.add(field).width(Config.SCREEN_WIDTH-40);
    stage = new Stage(new FillViewport(Config.SCREEN_WIDTH,Config.SCREEN_HEIGHT,new OrthographicCamera()),batch);
    stage.addActor(table);
    stage.setKeyboardFocus(field);
}
 
Example 33
Project: SuperUI   File: Handle.java   Source Code and License 5 votes vote down vote up
/**
 * A Handle can overwrite this function if you don't want to use the default
 * variadic parameter parsing.
 * 
 * @param parent
 * @param variadic
 */
public void initialise(Stage parent, Object... variadic) {
	this.parent = parent;

	int length = variadic.length;
	for (int i = 0; i < length; i++) {
		Object o = variadic[i];

		/** Register the class we get */
		register(o.getClass(), o);
	}
}
 
Example 34
Project: conquest   File: Match.java   Source Code and License 5 votes vote down vote up
public Match(Client client, Player player) {
    Match.client = client;
    this.tiles = Match.client.getMap();
    this.player = player;

    cam = new ConquestCamera(this.tiles);
    stage = new Stage(new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), cam));

    Group tileGroup = new Group();
    Group labelGroup = new Group();
    for (Tile t : this.tiles) {
        t.setTexture();
        tileGroup.addActor(t);
        labelGroup.addActor(t.getLabel());
    }

    Tile random = this.tiles.get(MathUtils.random(this.tiles.size - 1));
    while (random.getOwner() != Owner.None) {
        random = this.tiles.get(MathUtils.random(this.tiles.size - 1));
    }
    player.setCapital(random);
    client.send(random);

    cam.position.set(random.getX(Align.center), random.getY(Align.center), 0);

    stage.addActor(tileGroup);
    stage.addActor(labelGroup);
}
 
Example 35
Project: projecttd   File: OptionsScreen.java   Source Code and License 5 votes vote down vote up
@Override
public void show() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);

    VisUI.load();

    CenteredTableBuilder tableBuilder = new CenteredTableBuilder(new Padding(2, 3));

    VisLabel heading = new VisLabel("Options");
    heading.setColor(Color.BLACK);
    tableBuilder.append(heading).row();
    stage.addActor(heading);

    VisLabel temp = new VisLabel("To Be Implemented");
    temp.setColor(Color.BLACK);
    tableBuilder.append(temp).row();
    stage.addActor(temp);

    VisTextButton backButton = new VisTextButton("Back");
    backButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            ((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenuScreen());
        }
    });
    tableBuilder.append(backButton).row();
    stage.addActor(backButton);

    Table table = tableBuilder.build();
    table.setFillParent(true);
    stage.addActor(table);
}
 
Example 36
Project: gdx-controllerutils   File: ControllerMenuDialog.java   Source Code and License 5 votes vote down vote up
@Override
protected void setStage(Stage stage) {
    if (stage == null && getStage() != null && getStage() instanceof ControllerMenuStage) {
        for (int i = 0; i < buttonsToAdd.size; i++)
            ((ControllerMenuStage) getStage()).removeFocussableActor(buttonsToAdd.get(i));
    }

    super.setStage(stage);

    if (stage != null && stage instanceof ControllerMenuStage) {
        for (int i = 0; i < buttonsToAdd.size; i++)
            ((ControllerMenuStage) stage).addFocussableActor(buttonsToAdd.get(i));
    }
}
 
Example 37
Project: Tower-Defense-Galaxy   File: TDScreen.java   Source Code and License 5 votes vote down vote up
@Override
public void show () {
    //orthographicCamera = new OrthographicCamera(3840, 2160);
    matrix4 = new Matrix4();
    spriteBatch = new SpriteBatch();
    viewport = new FitViewport(2560, 1440, new OrthographicCamera());
    viewport.apply();
    stage = new Stage(viewport);
    camera = createCamera();
    multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(stage);
    Gdx.input.setInputProcessor(multiplexer);
    if(TDGalaxy.preferences.isDebug())
        stage.setDebugAll(true);
}
 
Example 38
Project: KyperBox   File: KyperBoxGame.java   Source Code and License 5 votes vote down vote up
@Override
public void create() {
	game_prefs = Gdx.app.getPreferences(prefs_name);

	game_stage = new Stage(view);
	game_states = new ObjectMap<String, GameState>();
	game_stage.setDebugAll(false);

	current_gamestates = new Array<GameState>();
	transition_state = new GameState(null);
	transition_state.setGame(this);

	assets = new AssetManager();
	assets.setLoader(TiledMap.class, new KyperMapLoader(assets.getFileHandleResolver()));
	assets.setLoader(ParticleEffect.class, new ParticleEffectLoader(assets.getFileHandleResolver()));
	assets.setLoader(ShaderProgram.class,
			new ShaderProgramLoader(assets.getFileHandleResolver(), VERTEX_SUFFIX, FRAGMENT_SUFFIX));
	sound = new SoundManager(this);

	packages = new Array<String>();
	packages.add("com.kyperbox.objects");

	global_data = new UserData(GAME_DATA_NAME);
	input = new GameInput();

	Gdx.input.setInputProcessor(game_stage);

	initiate();
}
 
Example 39
Project: summer17-android   File: Hud.java   Source Code and License 5 votes vote down vote up
public Hud(SpriteBatch sb) {
        worldTimer = 300;
        timeCount = 0;
        score = 0;

        viewport = new FitViewport(NoObjectionGame.V_WIDTH, NoObjectionGame.V_HEIGHT, new OrthographicCamera());
        stage = new Stage(viewport, sb);

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

//        countDownLabel = new Label(String.format("%03d", worldTimer), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
//        scoreLabel = new Label(String.format("%06d", score), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
//        timeLabel = new Label("TIME", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
//        levelLabel = new Label("1-1", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
//        worldLabel = new Label("WORLD", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
//        dudeLabel = new Label("DUDE", new Label.LabelStyle(new BitmapFont(), Color.WHITE));

        table.add(dudeLabel).expandX().padTop(10);
        table.add(worldLabel).expandX().padTop(10);
        table.add(timeLabel).expandX().padTop(10);
        table.row();
        table.add(scoreLabel).expandX();
        table.add(levelLabel).expandX();
        table.add(countDownLabel).expandX();

        stage.addActor(table);
    }
 
Example 40
Project: summer17-android   File: EndScreen.java   Source Code and License 5 votes vote down vote up
public EndScreen(NoObjectionGame game) {
    this.game = game;
    bg = new Texture("pixil-layer-Background2.png");
    viewport = new StretchViewport(NoObjectionGame.V_WIDTH, NoObjectionGame.V_HEIGHT, new OrthographicCamera());
    stage = new Stage(viewport, ((NoObjectionGame) game).batch);

}