We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Recently I looked into making sketches with multiple windows and found some code online that allowed me to achieve this. The code I wrote based of the code I found online is below:
Tab 1:
void setup() {
size(500, 500);
String[] args = {"TwoFrameTest"};
SecondApplet sa = new SecondApplet();
PApplet.runSketch(args, sa);
ThirdApplet ta = new ThirdApplet();
PApplet.runSketch(args, ta);
}
void draw() {
background(0);
ellipse(50, 50, 10, 10);
}
Tab 2:
public class SecondApplet extends PApplet {
public void settings() {
size(300, 300);
}
public void draw() {
background(255);
fill(0);
ellipse(100, 50, 10, 10);
}
}
public class ThirdApplet extends PApplet {
public void settings() {
size(400, 400);
}
public void draw() {
background(255);
fill(0);
ellipse(100, 50, 10, 10);
}
}
There is an issue however; when I run the code, the original window is displayed as its default size, even if a size method with different values is called. Strangely this even seems to happen if the other windows aren't called; the code in the second tab just has to be in the sketch folder and doesn't have to be referenced in any way. Does anybody have any idea what is happening and how I might fix it?
Answers
Since P3, functions size(), fullScreen(), smooth(), noSmooth() can only be used inside settings(): 3:-O
https://Processing.org/reference/settings_.html
However the PDE's pre-processor can seek out for them in the entire ".pde" files.
And if there's more than 1 found, pre-processor search will fail it seems. :-&
Your sketch contains 3 size() functions. Even though 2 are inside settings(), the pre-processor is too dumb and will fail to move the only size() inside setup() to its corresponding settings(). (:|
The fix is simply having all size() inside settings() once we use more than 1: *-:)
I've converted from Java Mode to Python Mode as well: :ar!