Thanks for the help.
I have been able to make the array but now I need help to convert it into an object.
The code without objects works, but when I try to do it I get errors.
What am I doing wrong?
I leave the code that works and the new one with the object that does NOT work.
Thanks!
WORKING CODE
import processing.video.*;
int maxVideos= 5;
Movie[] misVideos=new Movie[maxVideos] ;
ArrayList<PVector> videoPos = new ArrayList<PVector>();
ArrayList<Movie> videoPlay = new ArrayList<Movie>();
//randomize var
int rand = int(random(maxVideos));
void setup() {
size (1100, 600, P2D);
frameRate (60);
background(0);
for (int i = 0; i < misVideos.length; i ++ ) {
misVideos[i] = new Movie (this, "trazo"+nf(i, 2) + ".mov");
}
}
void mouseReleased() {
rand = int(random(maxVideos)); //Re-chooses the video
//store position:
videoPos.add(new PVector(mouseX, mouseY));
// add video to the list
videoPlay.add(misVideos[rand]);
}
void draw() {
background(0);
if (videoPlay.size() > 0) {
for (int i = 0; i< videoPlay.size(); i++ ) {
videoPlay.get(i).play();
imageMode(CENTER);
image(videoPlay.get(i), videoPos.get(i).x, videoPos.get(i).y);
}
}
//frameRate
frame.setTitle("fps" + frameRate);
}
void movieEvent(Movie m) {
m.read();
}
NOT WORKING
import processing.video.*;
ArrayList<PVector> videoPos = new ArrayList<PVector>();
ArrayList<Movie> videoPlay = new ArrayList<Movie>();
//Objet declaration:
Pincelada p;
void setup() {
size (1100, 600, P2D);
frameRate (60);
background(0);
//Inicialization:
p = new Pincelada();
}
void draw() {
background(0);
//frameRate
frame.setTitle("fps" + frameRate);
}
void mouseReleased() {
p.cuandoClickeo( );
}
////////////////////////
class Pincelada {
//1. Atributos
int maxVideos;
Movie[] misVideos;
//random var:
int rand;
//2. Constructor
Pincelada( Movie[] misVideos ) {
Movie[] misVideos = new Movie[maxVideos];
int maxVideos = 5;
for (int i = 0; i < misVideos.length; i ++ ) {
misVideos[i] = new Movie (this, "trazo"+nf(i, 2) + ".mov");
}
//3. Métodos
void dibujar( ) { /*<---ERROR unexpected token: void*/
if (videoPlay.size() > 0) {
for (int i = 0; i< videoPlay.size(); i++ ) {
videoPlay.get(i).play();
imageMode(CENTER);
image(videoPlay.get(i), videoPos.get(i).x, videoPos.get(i).y);
}
}
}
void mouseReleased() {
rand = int(random(maxVideos)); //randomize videos
//guardo la posición:
videoPos.add(new PVector(mouseX, mouseY));
// agrego un video a la lista
videoPlay.add(misVideos[rand]);
}
//draw videos
void movieEvent(Movie m) {
m.read();
}
read();
}
misVideos = new Movie[maxVideos];
maxVideos = 5;
for (int i = 0; i < misVideos.length; i ++ ) {
misVideos[i] = new Movie (this, "trazo"+nf(i, 2) + ".mov");
}
Hi, thanks for the answer but i’m still getting the same error "The constructor “Movie(Pinceladas, String)” does not exist.
//2. Constructor
Pinceladas() {
misVideos = new Movie[maxVideos];
maxVideos = 5;
for (int i = 0; i < misVideos.length; i ++ ) {
misVideos[i] = new Movie (this, "trazo"+nf(i, 2) + ".mov");
}
Thank you very much for your help, I really think there is a breakthrough.
Still, I run the code with your modifications and nothing happens, the screen goes black.
It throws me two errors:
the value of the parameter m is not used
void movieEvent(Movie m) {
p.misVideos[0].read();
}
dead code
for (int i = 0; i < misVideos.length; i++ ) { //<--- HERE
println( "trazo"+nf(i, 2) + ".mov");
misVideos[i] = new Movie (myApplet, "trazo"+nf(i, 2) + ".mov");
misVideos[i].loop();
break;
}
I don’t really understand about the PApplet myApplet parameters, but I’m doing some research on it.
It works! Thanks to your valuable contributions and last comments I was able to make the code work in an acceptable way.
Now I have to start investigating how to add a color mask to modify the strokes.
I would like to have a color palette assigned and that are varied randomly.
If you come up with a suggestion I will be very grateful, otherwise what you have contributed is invaluable.