개발/게임

Game menu always at bottom

slayernoone 2016. 11. 5. 00:39

http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=24084&p=98276&hilit=gui+menu#p98276




Game menu always at bottom

Postby Grzesiek » Wed Oct 26, 2016 7:56 pm

Hi,
I search at google how to create table as a sub menu with image buttons which will be always at screen bottom.
So far I created table with whole stuff I need, but table moves always when I move game world, but I need this table as a game menu at constant position at screen bottom.

Do you know any good solution or tutorial how to do this?

CODE: SELECT ALL
    protected void setupMenuTable() {
        menuTable = new Table();
        menuTable.setSize(AssetsManager.MENU_BUTTON_WIDTH, AssetsManager.MENU_BUTTON_HEIGHT * 5);
        menuTable.setFillParent(true);
        menuTable.align(Align.bottom);

        ImageButton endTurn = new ImageButton(getMenuButtonStyle(MainMenuButtons.NEW_GAME.name()));
        endTurn.addListener(new ChangeListener() {
            public void changed (ChangeEvent event, Actor actor) {
                game.setScreen( new GameScreenScreen(game));
                dispose();
            }
        });

        ImageButton mainMenu = new ImageButton(getMenuButtonStyle(MainMenuButtons.EXIT.name()));
        mainMenu.addListener(new ChangeListener() {
            public void changed (ChangeEvent event, Actor actor) {
                game.setScreen( new MainMenuScreen(game));
                dispose();
            }
        });

        menuTable.add(endTurn);
        menuTable.add(mainMenu).padLeft(10);
        stage.addActor(menuTable);
    }


CODE: SELECT ALL
    @Override
    public void render(float delta) {
        Gdx.gl.glClearColor(0.25f, 0.25f, 0.25f, 10f);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
        stage.draw();

        camera.update();
        renderer.setView(camera);
        renderer.render();
    }
Grzesiek
 
Posts: 8
Joined: Sun Oct 02, 2016 6:44 am

Re: Game menu always at bottom

Postby evilentity » Wed Oct 26, 2016 8:03 pm

You need to use another camera for gui only.
evilentity
 
Posts: 2947
Joined: Wed Aug 24, 2011 11:37 am

Re: Game menu always at bottom

Postby MMM1412 » Sun Oct 30, 2016 8:08 am

Or create a MenuStage , add your menu Into that, render MenuStage after game stage.