Instance Mode - calling other sketches

Even though I use & like that Processing sketch hosting site very much, for more complex sketches, I’d rather choose other hosting options w/ more code flexibility. :face_with_hand_over_mouth:

There are many approaches we can go with for multi-pick sketch. :motorway:

But b/c all the sketches you intend to run are using “instance mode”, that makes things much easier. :grin:

So I’ve come up with an example which uses createRadio() to pick the activeSketch from among those stored in sketches[]: :radio_button:

Every time the current option() is changed(), it calls back runPickedSketch(); which in turn calls destroyMe() for the activeSketch, then calls createMe() using the index - 1 from method value(). :nerd_face:

You can see it running online at this JS hosting site below: :running_man:

And also edit it here: Glitch :・゚✧
Fullscreen presentation: radio-pick-active-sketch.Glitch.me

P.S.: Due to a bug in methods option() & value(), I had to store sketches[]'s indices starting at 1, b/c those methods can’t store the value 0! :bug:

1 Like