diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-03 23:52:57 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-03 23:52:57 +0200 |
commit | 331143ef593ce24a76f6caadcd5f9dcce8783fb5 (patch) | |
tree | 884e9bdf48321b9e15d28812eba40d6223d1d98a /core/src | |
parent | c4d43b7a87bab33f1486af3d6ace82750026d0f9 (diff) | |
download | RustAndDust-331143ef593ce24a76f6caadcd5f9dcce8783fb5.zip RustAndDust-331143ef593ce24a76f6caadcd5f9dcce8783fb5.tar.gz |
MoveToAnimation: fix rotation
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/ch/asynk/tankontank/TankOnTank.java | 6 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/gfx/animations/MoveToAnimation.java | 13 |
2 files changed, 12 insertions, 7 deletions
diff --git a/core/src/ch/asynk/tankontank/TankOnTank.java b/core/src/ch/asynk/tankontank/TankOnTank.java index c2283dc..49cd23b 100644 --- a/core/src/ch/asynk/tankontank/TankOnTank.java +++ b/core/src/ch/asynk/tankontank/TankOnTank.java @@ -32,14 +32,11 @@ public class TankOnTank extends Game Gdx.app.debug("TankOnTank", " load assets : " + (Gdx.app.getJavaHeap()/1024.0f) + "KB"); manager.load("images/map_a.png", Texture.class); manager.load("images/map_b.png", Texture.class); - manager.load("images/dice.pack", TextureAtlas.class); manager.load("images/counters.pack", TextureAtlas.class); manager.load("images/ge.atlas", TextureAtlas.class); manager.load("images/us.atlas", TextureAtlas.class); manager.load("images/hex.atlas", TextureAtlas.class); manager.load("images/unit.atlas", TextureAtlas.class); - // manager.load("images/cup.jpg", Texture.class); - // manager.load("images/small.png", Texture.class); } public void unloadAssets() @@ -48,14 +45,11 @@ public class TankOnTank extends Game Gdx.app.debug("TankOnTank", "diagnostics:\n" + manager.getDiagnostics() ); manager.unload("images/map_a.png"); manager.unload("images/map_b.png"); - manager.unload("images/dice.pack"); manager.unload("images/counters.pack"); manager.unload("images/ge.atlas"); manager.unload("images/us.atlas"); manager.unload("images/hex.atlas"); manager.unload("images/unit.atlas"); - // manager.unload("images/cup.jpg"); - // manager.unload("images/small.png"); Gdx.app.debug("TankOnTank", "diagnostics:\n" + manager.getDiagnostics() ); } diff --git a/core/src/ch/asynk/tankontank/engine/gfx/animations/MoveToAnimation.java b/core/src/ch/asynk/tankontank/engine/gfx/animations/MoveToAnimation.java index 9a48db4..aa2e630 100644 --- a/core/src/ch/asynk/tankontank/engine/gfx/animations/MoveToAnimation.java +++ b/core/src/ch/asynk/tankontank/engine/gfx/animations/MoveToAnimation.java @@ -14,6 +14,7 @@ public class MoveToAnimation extends TimedAnimation private float toX; private float toY; private float toR; + private float rDelta; private static final Pool<MoveToAnimation> moveToAnimationPool = new Pool<MoveToAnimation>() { @Override @@ -36,6 +37,7 @@ public class MoveToAnimation extends TimedAnimation a.toY = y; a.toR = r; a.duration = duration; + a.rDelta = 0; return a; } @@ -58,6 +60,15 @@ public class MoveToAnimation extends TimedAnimation fromX = pawn.getX(); fromY = pawn.getY(); fromR = pawn.getRotation(); + + if (Math.abs(toR - fromR) <= 180.f) + rDelta = (toR - fromR); + else { + if (toR > fromR) + rDelta = (toR - 360 - fromR); + else + rDelta = (toR + 360 - fromR); + } } @Override @@ -72,6 +83,6 @@ public class MoveToAnimation extends TimedAnimation if (percent == 1f) pawn.setPosition(toX, toY, (int) toR); else - pawn.setPosition(fromX + ((toX - fromX) * percent), fromY + ((toY - fromY) * percent), (int) (fromR + ((toR - fromR) * percent))); + pawn.setPosition(fromX + ((toX - fromX) * percent), fromY + ((toY - fromY) * percent), (fromR + (rDelta * percent))); } } |