How to add a pop up menu in LibGDX?

Nehemiah Branson

I am trying to make a popup menu come up in libgdx but i can't figure out how to do it. I want it so that when I click an image on the screen I want it to pop up a smaller image on the screen where the user can buy items!

vdlmrc

For that, you can use a Table().

Put all the textures and buttons you need in that table and add the table to your stage, to display it on the screen.

If you want your table to pop up only when you click a button, there are several options. For example you can set your table invisible with table.setVisible(false), and when you click the button, you can make table.setVisible(true).

If you want to add some fancy animations, like sliding, scaling, fading... you'll have to look to the AddAction class. For example you can create your table outside the screen, let's say it is on the left of the screen, and when you click the button, the table will enter the screen by sliding to the right until it reaches the center of the screen. For that, you'll need to do something like that : table.addAction(Actions.moveTo(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2, 0.2f)))

Just look to the AddAction class, there are plenty of cool stuff to popup your menu.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related