Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 1a30f6ee04
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (42 sloc) 0.769 kB
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();
}
Jump to Line
Something went wrong with that request. Please try again.