So I have this array which contains UIElements (obviously);
public UIElement elements[] = {...}
and it contains classes that extend UIElements so that it’s easier for me to add and remove stuff;
public UIElement elements[] = {new Button("Back", 6, 104, 0), new SmallButton('<', 168, 32, 1), new SmallButton('>', 216, 32, 2), new SmallButton('C', 224, 64, 3),
new Button("Embark", 186, 104, 4), new Textbox("Wayne Smith", 32, 32, 5), new Label("Name", 8, 32), new Label("Race", 8, 48), new Label("Gender", 8, 64),
new Label("Clothing", 136, 48), new Label("Hair", 136, 64), new ArrayButton(new String[]{"Foreigner", "Native"}, 40, 48, 6),
new ArrayButton(new String[]{"Male", "Female"}, 40, 64, 7), new ArrayButton(new String[]{"Dungaree", "Jacket", "Loincloth", "F.Loincloth"}, 173, 48, 8),
new ArrayButton(new String[]{"Style A", "Style B"}, 173, 64, 9)};
For example; ArrayButtons store an array, an integer value and a scroll function (that changes that integer and sets the string on the button to show that element of the array)
HOWEVER, the problem is that I cannot simply;
player.race = elements[6].selection;
player.gender = elements[7].selection;
player.clothX = elements[8].selection / 2;
player.clothY = elements[9].selection % 2;
player.hairX = elements[10].selection;
Because the array contains UIElements, not ArrayButtons and I can’t access a variable that only exists in an ArrayButton
What can I do?