blob: 0c0d14debe3a611d49698866481dee204518ba71 (
plain)
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
|
package ch.asynk.rustanddust.engine.gfx.animations;
import com.badlogic.gdx.utils.Pool;
import ch.asynk.rustanddust.engine.gfx.Animation;
public abstract class TimedAnimation implements Animation, Pool.Poolable
{
private float time;
private boolean began;
private boolean completed;
protected float duration;
abstract protected void begin();
abstract protected void end();
abstract protected void update(float percent);
@Override
public void reset()
{
time = 0f;
began = false;
completed = false;
}
@Override
public boolean animate(float delta)
{
if (completed) return true;
if (!began) {
begin();
began = true;
}
time += delta;
completed = (time >= duration);
if (!completed) {
update(time / duration);
return false;
}
update(1);
end();
return true;
}
}
|