We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey, I'm trying to remove objects when home == false in order to clear the canvas to change the scene. Read somewhere that you had to do it with an ArrayList but I'm not confident at all with them and I'm probably doing something really dumb.
Also I'm not sure if this is the best way to change scenes.
Getting error: IndexOutOfBoundsException: Index: 0, Size: 0
Thanks heaps in advance.
int hunger;
int hungerIncrease = 1;
int happiness;
int happyIncrease = 1;
int jingling;
boolean home;
boolean shop;
Status status;
Button button;
ArrayList<Button> buttonL = new ArrayList<Button>(0);
ArrayList<Status> statusL = new ArrayList<Status>(0);
void setup() {
//window
size(320, 320);
//loading
status = new Status();
button = new Button();
buttonL.add(new Button());
statusL.add(new Status());
//variables
hunger = 5;
happiness = 5;
jingling = 50;
home = true;
shop = false;
}
void draw() {
if (home == true) {
Button bpart = buttonL.get(0);
bpart.show();
Status spart = statusL.get(0);
spart.show();
} else {
buttonL.remove(0);
statusL.remove(0);
}
////limits
if (hunger > 10) {
hunger = 10;
}
if (happiness > 10) {
happiness = 10;
}
}
void mouseClicked() {
if (home == true) {
button.clicked();
}
}
Answers
https://Forum.Processing.org/two/discussion/17562/how-to-iteratively-define-variables#Item_1