-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScreenTransition.pde
61 lines (48 loc) · 1.24 KB
/
ScreenTransition.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
/*
* Effect of screen transition, FADE to black is the default
*/
import de.looksgood.ani.*;
public abstract class StateTransition {
float duration = 0.200;
float delay = 0;
public Object callBackObject;
public String callBackName = "onEnd:leaveStateAfterTransition";
boolean enabled;
boolean isPlaying;
protected Ani animation;
abstract void execute();
abstract boolean isPlaying();
}
public class SceneTransition extends StateTransition {
color c = color(1,1,1);
int w;
int h;
int alpha = 0;
int start = 0;
int to = 255;
de.looksgood.ani.easing.Easing easing = AniConstants.QUAD_OUT;
public SceneTransition() {
w = width;
h = height;
callBackObject = stateHandler;
}
public void execute() {
c = (c & 0xffffff) | (start << 24);
alpha = start;
isPlaying = true;
enabled = true;
animation = Ani.to(this, duration, delay, "alpha", float(to), easing, callBackObject, callBackName);
}
public void display() {
if (enabled) {
noStroke();
fill((c & 0xffffff) | (alpha << 24));
rectMode(CORNER);
rect(0, 0, w, h);
}
}
boolean isPlaying() {
boolean ret = animation != null && (animation.isPlaying() || animation.isDelaying());
return ret;
}
}