Movie objects all change at the same time

Hello Processors, thank you for your time. I made this object using a Movie object where two videos float up and stay in the top. It works but I also typed a function for each of them to change color when I click on them. It changes the color of all of them at the same time.

import processing.video.*;
Movie myMovie;
Video v1;
Video v2; 

void setup() {
  size(640, 360);
  myMovie = new Movie(this, "fogata.mp4");
  myMovie.loop();
  v1 = new Video(4096/20, 2160/20);
  v2 = new Video(4096/40, 2160/40);// this is calling the constructor
}

void draw() {
  background(255);
  v1.display();
  v1.ascend();
  v1.top();

  v2.display();
  v2.ascend();
  v2.top();
}

//tint
void mouseClicked() {
  v2.tintit();
  v1.tintit();
}
void movieEvent(Movie m) {
  m.read();
}

class Video {

  //data
  float x;
  float y;
  float sizeW;
  float sizeH;
  float d;

  Video(float tempW, float tempH) {//here is where initialization starts
    x = width/2*random(0, 3);
    y = height;
    sizeW = tempW;
    sizeH= tempH;
  }
  void ascend() {
    y--;
    x = x + random(-2, 2);
  }

  void top() {
    if (y < sizeH/2) {
      y = sizeH/2;
    }
  }

  //functuality: function definitions
  void display() {
    image(myMovie, x, y, sizeW, sizeH);
  }
  
  void tintit() {
    d  = dist(mouseX, mouseY, x, y);
    if (d < sizeW && d <sizeW) {
      tint(0, 206, 16);
    }
  }
}
1 Like

You don’t have any code that check whether the mouse is inside one of the videos. When you click the mouse, anywhere, you tint both videos.

You need to add some code that checks which video you’re in when you click the mouse.

Shameless self-promotion: here is a guide on collision detection in Processing. You’re looking for rectangle-point collision detection.

1 Like

hehe I will look into the collision detection guide.