blob: ccfe614cdf2e757f9b3d255a024a00b30d7b08ac (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
package ch.asynk.rustanddust.engine.gfx.animations;
import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import ch.asynk.rustanddust.engine.gfx.Moveable;
import ch.asynk.rustanddust.engine.gfx.Animation;
public class DestroyAnimation implements Disposable, Animation
{
private static final float DELAY = 1.5f;
private static final float DURATION = 1.0f;
private Moveable moveable;
private float x;
private float y;
private int alphaP;
private float elapsed;
@Override
public void dispose()
{
}
public void set(float duration, Moveable moveable)
{
this.moveable = moveable;
this.alphaP = 0;
this.elapsed = 0f;
this.x = (moveable.getX() + (moveable.getWidth() / 2f));
this.y = (moveable.getY() + (moveable.getHeight() / 2f));
}
@Override
public boolean animate(float delta)
{
elapsed += delta;
if (elapsed < DELAY)
return false;
int a = (int) (((elapsed - DELAY) / DURATION) * 10);
if (a != alphaP) {
alphaP = a;
moveable.setAlpha(1f - (alphaP / 10f));
}
return (elapsed >= (DELAY + DURATION));
}
@Override
public void draw(Batch batch)
{
moveable.draw(batch);
}
@Override
public void drawDebug(ShapeRenderer debugShapes)
{
moveable.drawDebug(debugShapes);
}
}
|