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.


'개발 > 게임' 카테고리의 다른 글

Is Table the only layout that I can use in libgdx?  (0) 2016.11.05
LibGDX 구조  (0) 2016.11.03
How can I map regions on a world map image?  (0) 2016.11.01



1. Screen > Stage > Actor > Action 요렇게 구성되는거 같다.

'개발 > 게임' 카테고리의 다른 글

Is Table the only layout that I can use in libgdx?  (0) 2016.11.05
Game menu always at bottom  (0) 2016.11.05
How can I map regions on a world map image?  (0) 2016.11.01

http://gamedev.stackexchange.com/questions/92038/how-can-i-map-regions-on-a-world-map-image



You could use polygons, or you could do a quick and dirty hack and just get a political map like this one: this one. Then, pick a unique color for each country and flood fill it in paint or photoshop. Then, you have a simple file that just has the mapping of countries/provinces to particular colors. Just something like this:

# Country,      #Unique RGB color
"Afghanistan",     (0, 0, 0)
"Albania",         (1, 0, 0)
...
"United Kingdom",  (255, 0, 0)
"United States",   (0, 1, 0)
...
"Kingdom of Zzyx", (0, 255, 0)
"ZZZland",         (0, 0, 1)
...

Then, when the player clicks on the map, just sample the color image, and find the color associated with it. Of course, this will be limited to the resolution of the selection image. This also gives you control over the political boundaries you want to select. For instance, if you just want to select continents, you could use an image like this: image

'개발 > 게임' 카테고리의 다른 글

Is Table the only layout that I can use in libgdx?  (0) 2016.11.05
Game menu always at bottom  (0) 2016.11.05
LibGDX 구조  (0) 2016.11.03

+ Recent posts