mouse/mouseY
in
Android Processing
•
5 months ago
Hello,
i have following sketch:
- Car myCar1;
- Car myCar2; // Two objects!
- void setup() {
- size(400,800);
- // Parameters go inside the parentheses when the object is constructed.
- myCar1 = new Car(color(255,0,0),10,0,2);
- myCar2 = new Car(color(0,0,255),100,0,1);
- }
- void draw() {
- background(255);
- myCar1.drive();
- myCar1.display();
- myCar2.drive();
- myCar2.display();
- }
- // Even though there are multiple objects, we still only need one class.
- // No matter how many cookies we make, only one cookie cutter is needed.
- class Car {
- color c;
- float xpos;
- float ypos;
- float xspeed;
- // The Constructor is defined with arguments.
- Car(color tempC, float tempXpos, float tempYpos, float tempXspeed) {
- c = tempC;
- xpos = tempXpos;
- ypos = tempYpos;
- xspeed = tempXspeed;
- }
- void display() {
- stroke(0);
- fill(c);
- rectMode(CENTER);
- rect(xpos,ypos,75,75);
- }
- void drive() {
- ypos = ypos + xspeed;
- if (ypos > height) {
- ypos = 0;
- }
- }
- }
Now I'd like to set the ypos to 0 when you touch this objects on your smartphone.
How can i solve this?
I tried if(mouseX=xpos && mouseY=ypos)....but this didn't work.
1