Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
dmtrs
dmtrs's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Combine Multiple Sketches
[0 Replies]
25-Jul-2013 05:49 AM
Forum:
Integration and Hardware
Hello everyone,
I am trying to combine multiple sketches and switch between those sketches for a vjing event in 2 weeks.
At first I thought of using a different software but now I'm just trying to combine them in a single sketch as discussed in
http://www.processing.org/discourse/beta/num_1266418665_30.html
.
My problem is that my TestCode works in Processing but when i run it in Eclipse it gives me a gray screen and no error.
Anyone knows what the problem is?
Thanks.
code:
package combinerTest;
import java.lang.reflect.Constructor;
import processing.core.PApplet;
import processing.core.PImage;
public class Combiner extends PApplet {
private static final long serialVersionUID = 1L;
final int W = 640;
final int H = 480;
int BG = 0;
int fps = 30;
int seconds = 6;
PApplet[] sketches;
String[] names;
int s;
public void setup() {
size(W, H);
Class<?>[] classes = getClass().getDeclaredClasses();
int n = classes.length;
sketches = new PApplet[n];
names = new String[n];
for (int i = 0; i < n; i++) {
try {
Constructor<?> c = classes[i]
.getDeclaredConstructor(getClass());
sketches[i] = (PApplet) c.newInstance(this);
sketches[i].init();
names[i] = split(c.getName(), "$")[1];
} catch (Exception e) {
}
}
frameRate(fps);
}
public void draw() {
if (frameCount % (seconds * fps) == 1) {
// stop running sketch
if (frameCount > 1) {
println("stopping " + names[s]);
sketches[s].stop();
s = (s + 1) % sketches.length;
}
// start next sketch
println("starting " + names[s]);
sketches[s].run();
}
sketches[s].handleDraw();
PImage img = sketches[s].get();
img.loadPixels();
image(img, 0, 0);
}
class Sketch1 extends PApplet {
private static final long serialVersionUID = 1L;
public void setup() {
size(W, H);
}
public void draw() {
background(BG);
ellipse(W / 2, H / 2, 20, 20);
}
}
class Sketch2 extends PApplet {
private static final long serialVersionUID = 1L;
public void setup() {
size(W, H, P2D);
}
public void draw() {
background(BG);
ellipse(W / 2, H / 2, 20, 20);
}
}
class Sketch3 extends PApplet {
private static final long serialVersionUID = 1L;
public void setup() {
size(W, H, P3D);
}
public void draw() {
background(BG);
lights();
noStroke();
translate(W / 2, H / 2, 0);
sphere(10);
}
}
public static void main(String _args[]) {
PApplet.main(new String[] { combinerTest.Combiner.class
.getName() });
}
}
«Prev
Next »
Moderate user : dmtrs
Forum