Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (799)
Games in Android Showcase (236)
games submitted by our members
Games in WIP (865)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  LibGDX and Scene2d - simple menu issue  (Read 2929 times)
0 Members and 1 Guest are viewing this topic.
Offline israelg99
« Posted 2015-04-16 02:23:11 »

I am using LibGDX and Scene2D to create a simple menu for my game.<br />
Here is a simple example that works for me:

1  
2  
3  
4  
    table.add(gameLogo).row();
    table.add(button1).row();
    table.add(button2).row();
    table.add(button3).row();

I didn't include the irrelevant code(including the table into the stage for example).<br/>

If I don't include `.row()` to each object that I add to the table, then the menu isn't aligning to the center, which is very odd, for example:

1  
2  
3  
4  
    table.add(gameLogo).row();
    table.add(button1);
    table.add(button2).row();
    table.add(button3);

Why is the menu behaving like that? should I use more `Tables` or add some `HorizontalGroups` perhaps?

If you need any additional information, or images I can provide, although it does the same for even the simplest menu implemention possible with LibGDX and Scene2d.

Offline atombrot
« Reply #1 - Posted 2015-04-16 06:48:41 »

I'm not sure what the weird behavior is you are experiencing, as the table does what you told it to. Your first example would create a table with 1 column and 4 rows, the second example will produce a table with 2 columns and 2 rows.

If you want to understand how the table functions it's best to check out the docs of the github project: https://github.com/EsotericSoftware/tablelayout

If you understand what is explained on that page you should be ready to go to make some layouts. One last note. Don't try to make your tables too complicated. You can nest them (put a table in the cell of another table) and achieve more complex layouts with this. Just make a draft of your screen on paper and try to find out how you could structure the screen with the help of tables.
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 167
Projects: 5
Exp: 6 years



« Reply #2 - Posted 2015-04-16 06:52:14 »

It's a table, so it'll align to rows and columns. If you want it centered, try colspan() to make a cell extend horizontally.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline israelg99
« Reply #3 - Posted 2015-04-17 00:13:39 »

It's a table, so it'll align to rows and columns. If you want it centered, try colspan() to make a cell extend horizontally.

I will try it now, sounds like the answer!
Yeah I just figured out it's a table :0
I guess that's what happening when you binge a programming session on your game haha Smiley

Pages: [1]
  ignore  |  Print  
 
 

 
Riven (183 views)
2019-09-04 15:33:17

hadezbladez (4859 views)
2018-11-16 13:46:03

hadezbladez (1783 views)
2018-11-16 13:41:33

hadezbladez (5131 views)
2018-11-16 13:35:35

hadezbladez (1013 views)
2018-11-16 13:32:03

EgonOlsen (4356 views)
2018-06-10 19:43:48

EgonOlsen (5213 views)
2018-06-10 19:43:44

EgonOlsen (2940 views)
2018-06-10 19:43:20

DesertCoockie (3865 views)
2018-05-13 18:23:11

nelsongames (4290 views)
2018-04-24 18:15:36
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!