forked from michael/tween
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtween1.pjs
51 lines (42 loc) · 769 Bytes
/
tween1.pjs
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
class MovingObject {
float x;
float y;
float tx;
float ty;
Tween t;
Tween t2;
public MovingObject(float x, float y, float tx, float ty) {
this.x = x;
this.y = y;
this.tx = tx;
this.ty = ty;
t = new Tween(this, "x", Tween.strongEaseInOut, x, tx, 2);
t2 = new Tween(this, "y", Tween.bounceEaseInOut, y, ty, 2);
}
public void update() {
t.tick();
t2.tick();
}
public void draw() {
noStroke();
fill(120);
ellipse(x, y, 30, 30);
}
public void restart() {
t.start();
t2.start();
}
}
MovingObject mo;
void setup() {
size(400, 150);
mo = new MovingObject(50, 30, 360, 130);
}
void draw() {
background(244);
mo.update();
mo.draw();
}
void mousePressed() {
mo.restart();
}