summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2018-11-14 00:18:27 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2018-11-14 00:18:27 +0100
commit01093ee759f5cf9f9c260fa9ef61b87201fe7130 (patch)
tree40f981bce09019f6be4357fb7acc1ffb5ca2227d
parent77019ebdf77f8207901e10fea967bb3a1765ee6c (diff)
downloadgdx-boardgame-01093ee759f5cf9f9c260fa9ef61b87201fe7130.zip
gdx-boardgame-01093ee759f5cf9f9c260fa9ef61b87201fe7130.tar.gz
TimedAnimation : add float elapsed parameter to update(…)
-rw-r--r--core/src/ch/asynk/gdx/boardgame/animations/BounceAnimation.java2
-rw-r--r--core/src/ch/asynk/gdx/boardgame/animations/DelayAnimation.java2
-rw-r--r--core/src/ch/asynk/gdx/boardgame/animations/TimedAnimation.java9
3 files changed, 8 insertions, 5 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/animations/BounceAnimation.java b/core/src/ch/asynk/gdx/boardgame/animations/BounceAnimation.java
index cd4f3aa..cda604c 100644
--- a/core/src/ch/asynk/gdx/boardgame/animations/BounceAnimation.java
+++ b/core/src/ch/asynk/gdx/boardgame/animations/BounceAnimation.java
@@ -72,7 +72,7 @@ public class BounceAnimation extends TimedAnimation implements Pool.Poolable
}
}
- @Override protected void update(float percent)
+ @Override protected void update(float elapsed, float percent)
{
piece.setScale(this.startScale + this.bounceFactor * (float) Math.sin(percent * Math.PI));
if (rotationDegrees != 0f) {
diff --git a/core/src/ch/asynk/gdx/boardgame/animations/DelayAnimation.java b/core/src/ch/asynk/gdx/boardgame/animations/DelayAnimation.java
index 695a21a..4ce6097 100644
--- a/core/src/ch/asynk/gdx/boardgame/animations/DelayAnimation.java
+++ b/core/src/ch/asynk/gdx/boardgame/animations/DelayAnimation.java
@@ -43,7 +43,7 @@ public class DelayAnimation extends TimedAnimation implements Pool.Poolable
@Override protected void begin() { }
@Override protected void end() { }
- @Override protected void update(float percent) { }
+ @Override protected void update(float elapsed, float percent) { }
@Override public void draw(Batch batch)
{
diff --git a/core/src/ch/asynk/gdx/boardgame/animations/TimedAnimation.java b/core/src/ch/asynk/gdx/boardgame/animations/TimedAnimation.java
index 3d35dd9..3f351d2 100644
--- a/core/src/ch/asynk/gdx/boardgame/animations/TimedAnimation.java
+++ b/core/src/ch/asynk/gdx/boardgame/animations/TimedAnimation.java
@@ -6,10 +6,11 @@ public abstract class TimedAnimation implements Animation
{
private float dp;
private float percent;
+ private float elapsed;
abstract protected void begin();
abstract protected void end();
- abstract protected void update(float percent);
+ abstract protected void update(float elapsed, float percent);
public void setDuration(float duration)
{
@@ -19,6 +20,7 @@ public abstract class TimedAnimation implements Animation
public void reset()
{
percent = 0f;
+ elapsed = 0f;
}
@Override public boolean completed()
@@ -32,7 +34,8 @@ public abstract class TimedAnimation implements Animation
begin();
}
- percent += (dp * delta);
+ elapsed += delta;
+ percent = (dp * elapsed);
if (percent >= 1f) {
// percent = 1f;
@@ -40,7 +43,7 @@ public abstract class TimedAnimation implements Animation
end();
return true;
} else {
- update(percent);
+ update(elapsed, percent);
return false;
}
}