for loop in a class
in
Core Library Questions
•
6 months ago
hi processing community,
im a bit of a processing newbie and perhaps you can help me:
I want to make a programm where there are 5 small movies that i can drag around ..
so far it all works fine but my problem is that the for loop in the Circle class i guess.
the code only shows me the same movie, i guess that the display block in the circle class is not looping.
and the array and the for loop has no influence on the image(eye[i],xpos,ypos,304,224); in line 95
can anybody help me with that?
sorry for my bad englisch
Thanks for any help
- import processing.video.*;
- Movie myMovie;
- Movie myMovie2;
- Movie [] eye = new Movie [5];
- Circle [] circles = new Circle[5];
- void setup()
- {
- eye[0] = new Movie(this, "eye.mov");
- eye[0].loop();
- eye[1] = new Movie(this, "eye.mov");
- eye[1].loop();
- eye[2] = new Movie(this, "eye.mov");
- eye[2].loop();
- eye[3] = new Movie(this, "eye.mov");
- eye[3].loop();
- eye[4] = new Movie(this, "eye2.mov");
- eye[4].loop();
- size(1920,1000);
- smooth();
- for (int i = 0; i < circles.length; i++)
- {
- circles[i] = new Circle();
- }
- }
- void draw()
- {
- background(0);
- for (int i = 0; i < circles.length; i++)
- {
- circles[i].display();
- }
- }
- void mouseDragged()
- {
- for (int i = 0; i < circles.length; i++)
- {
- circles[i].move();
- }
- }
- class Circle
- {
- float r;
- float xpos;
- float ypos;
- Circle()
- {
- xpos = random(width);
- ypos = random(height);
- noFill();
- r = 10;
- }
- void display()
- {
- noStroke();
- //fill(255,80);
- for (int i = 0; i < eye.length; i++)
- {
- image(eye[i],xpos,ypos,304,224);
- }
- rect(xpos,ypos,r*2,r*2);
- loop();
- }
- void move()
- {
- if(dist(mouseX,mouseY,xpos,ypos)<r)
- {
- xpos = mouseX;
- ypos = mouseY;
- if (xpos>width || ypos>height) {
- xpos = 0;
- ypos = 0;
- }
- }
- }
- }
- void movieEvent(Movie m) {
- m.read();
- }
1