1
votes

I'm trying to create a simple vertical list of buttons and labels using Libgdx VerticalGroup and adding the buttons to the vertical group. Unfortunately they appear to be stacking in the bottom left corner of the stage and not vertically. Does anyone have an idea of why this might be? I defined my TextButton styles manually so I was thinking maybe the vertical group doesn't know how tall they are for some reason and it just stacks them on top of each other? I really don't want to make a skin because there seems to be no comprehensive way to make one. I've tried in the past and it has never worked easily. All I want to do is make one simple vertical layout with some buttons. Here is the gist of my code (I've tried many different options but this is basically it):

vg = new VerticalGroup();
vg.setFillParent(true);
resumeButton = new TextButton("Resume", buttonStyle64x16);
vg.addActor(resumeButton);
// ...add more buttons...
stage.addActor(vg);

Button Style def:

buttonStyle64x16 = new TextButton.TextButtonStyle();
buttonStyle64x16.up = new TextureRegionDrawable(Assets.button64x16);
buttonStyle64x16.down = new TextureRegionDrawable(Assets.button64x16_down);
buttonStyle64x16.font = Assets.fontMedium;
1

1 Answers

3
votes

just tested your code, and I think I show it as wanted.

Tested code using a VerticalGroup

VerticalGroup vg = new VerticalGroup();
vg.setFillParent(true);
TextButton resumeButton = new TextButton("Resume", skinMenuPrincipal);
TextButton resumeButton1 = new TextButton("Resume1", skinMenuPrincipal);
TextButton resumeButton2 = new TextButton("Resume2", skinMenuPrincipal);
vg.addActor(resumeButton);
vg.addActor(resumeButton2);
vg.addActor(resumeButton1);

stage.addActor(vg);

Image

if so the error I think is in your buttons as you say, on the other hand if you want to put some actors elsewhere, you could also do it with one table class.

Table.add(actor).row();
Table.add(actor1).row();
Table.add(actor2).row();