-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMultiTouch.pde
64 lines (63 loc) · 1.35 KB
/
MultiTouch.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import android.view.MotionEvent;
class MultiTouch{
pt currentTouch, lastTouch, disk;
Pin p;
boolean selected;
int meIndex;
pt movement;
MultiTouch(){
currentTouch=new pt();
lastTouch= new pt();
disk=new pt();
selected=false;
meIndex=-1;
p=new Pin();
}
MultiTouch(float x,float y,float z){
currentTouch=new pt();
lastTouch= new pt();
disk=new pt(x,y,z);
selected=false;
meIndex=-1;
}
void lift(){
//this.meIndex=-1;
this.selected=false;
}
void movement(int pointerId, MotionEvent ev){
currentTouch=new pt(ev.getX(pointerId),ev.getY(pointerId),0);
disk.move(currentTouch.subtract(lastTouch));
lastTouch.set(currentTouch);
}
void touch(int pointerId,MotionEvent ev){
this.meIndex=pointerId;
this.selected=true;
this.lastTouch=new pt(ev.getX(pointerId),ev.getY(pointerId),0);
}
void draw(){
if(this.selected){
fill(0,255,0);
this.disk.draw();
}
else{
fill(255,0,0);
this.disk.draw();
}
}
String toString(){
String ret="";
ret+= "disk: "+disk;
ret+= " currentTouch: "+currentTouch+" lastTouch: "+lastTouch+" meIndex: "+meIndex+ "Selected: "+selected;
return ret;
}
ArrayList getHistory(){
//Need to implement
return null;
}
void setPin(Pin pin){
p=pin;
}
void resetPin(){
p=new Pin();
}
}