Hi guys,
For a multiplayer lobby I would have to show a list of all the rooms that a player can join and that is something a LIST can nicely do. But.... I would like for each list item to be a string + a button (JOIN) to the right of that text string.
So 1 item of the list should have both a text string and a button.
Currently I don't find how to do that.
The names of my lobbies are in array lobbies and I need to create a list out of that + listen to the clicks on those buttons.
Any suggestions? Possible?
This code is not doing it
function ready(frame, stage) {
const data = [];
["Lobby", "Room demo", "Room games", "Room test"].forEach(room => {
const row = new Container(600, 50);
new Label({
text: room,
size: 20,
color: dark
}).pos(20, 15, row);
const btn = new Button({
label: "Join",
width: 80,
height: 30
}).pos(500, 10, row);
btn.on("click", () => {
console.log("Join:", room);
});
data.push(row);
});
const list = new List({
list: data,
width: 600,
height: 300,
spacing: 2,
backgroundColor: "#eeeeee",
corner: 5
}).center();
stage.update();
}
Kind regards,
Bart