guys. I was looking at an article that drew a list of selectable sequences in a scrollable layout for the game LibGDX. I did everything according to the lesson, but the mena doesn't have a choice of items.
public ChangeSongState(GameStateManager game) {
super(game);
atlas = new TextureAtlas(Gdx.files.internal("uiskin.atlas"));
skin = new Skin(Gdx.files.internal("SimpleSkin.json"), atlas);
}
@Override
public void update(float dt) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(dt);
stage.draw();
}
@Override
public void render(SpriteBatch sb) {
gameWidth = Gdx.graphics.getWidth();
gameHeight = Gdx.graphics.getHeight();
list = new List<String>(skin);
String[] strings = new String[20];
for (int i = 0, k = 0; i < 20; i++) {
strings[k++] = "String: " + i;
}
list.setItems(strings);
scrollPane = new ScrollPane(list);
scrollPane.setBounds(0, 0, gameWidth, gameHeight + 100);
scrollPane.setSmoothScrolling(false);
scrollPane.setPosition(gameWidth / 2 - scrollPane.getWidth() / 4,
gameHeight / 2 - scrollPane.getHeight() / 4);
scrollPane.setTransform(true);
scrollPane.setScale(0.5f);
stage = new Stage(new StretchViewport(gameWidth, gameHeight));
stage.addActor(scrollPane);
Gdx.input.setInputProcessor(stage);
}
Json-file:
"com.badlogic.gdx.scenes.scene2d.ui.List$ListStyle": {
"default": {
"font": "default-font",
"fontColorUnselected":"blue",
"fontColorSelected":"white",
"selection": "selection"
}
}
Can't understand why I can't select a list item