We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Howdy, i'm doing a work and I want to, by a menu with several options, click an option and a diferent sketch appears in a pop up window, i have already all the sketches done I just need to "glue" them together and i dont know how, I've tried multisketch but i don't think it lets me use more than two sketches. please help!! thanks 8)
Answers
Please do not post multiple copies of the same question. I've deleted your duplicate post.
You'll have better luck if you try something out and post some example code. What have you tried with multisketch?
oh sorry, in this example they only use two sketches, one in a class and other in none, what i want is to from a menu sketch access other sketches. that would need multiple classes i think, but if i put the other sketch in a class it doesn't work and i dont know how to use more than two sketches in multisketch.
for example, using this menu i would pop up another sketch
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text
see
http://forum.processing.org/two/discussion/10678/menu-in-processing#latest
Multiple PApplet sketches w/o relying on PopupWindow: :-h
Thanks i love you
why is
the lenght-2 ? i tought it was suppose to be one because you know [3] its 0, 1, 2, 3 and so on
ok so the sketches are being initiated in the main sketch's setup but the setup only runs once right? now if i wanted to make for example
what would i do?
getClasses() ends up returning 2 internal PApplet classes besides the 1s we implemented ourselves!
They seem always being the last 2 classes obtained. That's why
nested.length - 2
skips them! :ar!void
and doesn't return anything.public
norstatic
as main() demanded! \m/it can save & track their references in variables it has control of! *-:)
http://docs.oracle.com/javase/8/docs/api/java/awt/Component.html#setVisible-boolean-
https://processing.org/reference/noLoop_.html
https://processing.org/reference/loop_.html
you're just awsome.
also see
http://forum.processing.org/two/discussion/comment/43341/#Comment_43341
Yes I have a problem my beloved I just united 4 sketches to a main sketch due to your aid, but in the menu the moment I select a sketch to run the program just breaks if you could take a look it would be awsome
Sorry about the genesis testament but you can skip most of the code
Only 1 of the sketches can use an OpenGL-based renderer: P2D, P3D, OPENGL.
In other words, the rest gotta be JAVA2D renderer!
that means i have to cut down one sketch, thanks :)
Ok i have cut down one sketch and made the changes necessary but when i select one it breaks and says NULL POINTER EXCEPTION
In my own example, all of them uses JAVA2D.
And if you change only 1 of them to something else, you'll see they'll still work.
Only when more than 1 is diff. than JAVA2D it crashes.
Now I dunno why you got an NPE.
The code you posted is half green characters and hard to get my brain focused! 8-X
can you read all the code i updated? cus i cant, and its not green anymore xD
What I see is an incomplete letras() function.
You didn't say what was wrong with it...
well i put all the code in the comment but only that showed up
I can't guess where the NPE occurred! Is it at
image(title, width/2, 10);
?If so you just need to make sure title holds some PImage reference.
Although I might say this isn't about "multiple sketches" anymore but rather common NPE bug hunt! :-<
its at p.frame.show() in the activate sketch
well i didnt add to my code the togglesketch class maybe thats it
nor the runSketch,
I DID IT PROBLEM SOLVED
As you noticed, I've called main() in order to instantiate & ignite all nested PApplet sketches. However, main() is void and doesn't return anything. Therefore, we don't get hold of the references as a way to track those nested sketches! In place of main(), we'll rely on runSketch() from now on. This 1 allows us to pass an already instantiated PApplet as its 2nd argument. As a bonus, sketches don't need to be public nor static as main() demanded! Since the main PApplet sketch was responsible to directly instantiate the other nested 1s, it can save & track their references in variables it has control of! Other key ingredients are setVisible(), noLoop() & loop() methods: http://docs.oracle.com/javase/8/docs/api/java/awt/Component.html#setVisible-boolean- https://processing.org/reference/noLoop_.html https://processing.org/reference/loop_.html With them, we can pause/resume & hide/show any PApplet which we hold the reference! Check out latest (v2.0) below. Any doubts just ask here again:
But when one of those windows is closed, it kills the entire program... how might one handle closing any of the three windows individually without killing the program?
Is there any solution for this problem running in P3 resp. a version of Multiple Nested PApplets by GoToLoop for P3?
Just move all size() & smooth() to settings() for P3:
https://Processing.org/reference/settings_.html