I am trying to change layout in an Android app in Processing, layouts just being 2 different methods that are run inside void draw(), but the program seems to fail to recognize the change of the currentLayout value that I am trying to change in void OscEvent.
When I print currentLayout in OscEvent, the value changes and sets to 2 as it should, but if I print it in draw() it never changes. So this is what is happening:
- I can print "change!"
- the value of currentLayout is changed and noticed if I check it inside OscEvent()
- the value of currentLayout is NOT changed nor noticed if I check it inside draw()
- I am also able to change the value, and layout, successfully when i do it in methods that are not from the OscP5 library, I am not sure how that affects anything.
The important parts of the code:
public int currentLayout;
void setup() {
currentLayout=1;//vilken scen man börjar på, kolla switchen i draw()
}
void draw() {
switch(currentLayout) {
case 1:
defaultLayout();
break;
case 2:
task1();
break;
}
println(currentLayout);
}
void oscEvent(OscMessage theOscMessage) {
/* get and print the address pattern and the typetag of the received OscMessage */
String[] list =split(theOscMessage.addrPattern(), '/');
println(list[1]);
if (list[1].equals("layout")) {
println("change!");
currentLayout=2;
}
}
All help and suggestions are appreciated! Thanks.