diff options
| author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-12-05 23:38:54 +0100 | 
|---|---|---|
| committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-12-05 23:38:54 +0100 | 
| commit | fd7058b8554b2e46a4b56ea824d6fbf48008f4d2 (patch) | |
| tree | 57bebb5e262c1d6b08d217462fbdfc02213fce7c | |
| parent | ae06c83c52a9058d01252b2c557f6340b93b7b81 (diff) | |
| download | RustAndDust-fd7058b8554b2e46a4b56ea824d6fbf48008f4d2.zip RustAndDust-fd7058b8554b2e46a4b56ea824d6fbf48008f4d2.tar.gz | |
add DestroyAnimation
| -rw-r--r-- | core/src/ch/asynk/tankontank/engine/gfx/animations/DestroyAnimation.java | 62 | 
1 files changed, 62 insertions, 0 deletions
| diff --git a/core/src/ch/asynk/tankontank/engine/gfx/animations/DestroyAnimation.java b/core/src/ch/asynk/tankontank/engine/gfx/animations/DestroyAnimation.java new file mode 100644 index 0000000..da05d1a --- /dev/null +++ b/core/src/ch/asynk/tankontank/engine/gfx/animations/DestroyAnimation.java @@ -0,0 +1,62 @@ +package ch.asynk.tankontank.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.tankontank.engine.gfx.Moveable; +import ch.asynk.tankontank.engine.gfx.Animation; + +public class DestroyAnimation implements Disposable, Animation +{ +    private static final float DELAY = 1.5f; +    private static final float DURATION = 1.5f; + +    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); +    } +} | 
