diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-27 15:35:48 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-27 15:35:48 +0100 |
commit | 655e19401debae60e029a4ceca41caeb52a80ad3 (patch) | |
tree | 17513a1c03ac84596e664636030cd236677cf56b /core/src/ch/asynk/tankontank/engine | |
parent | 5d81af80867965dc5be81098ec0e6e8a740e0ce7 (diff) | |
download | RustAndDust-655e19401debae60e029a4ceca41caeb52a80ad3.zip RustAndDust-655e19401debae60e029a4ceca41caeb52a80ad3.tar.gz |
ShotAnimation: use explosion sounds
Diffstat (limited to 'core/src/ch/asynk/tankontank/engine')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/gfx/animations/ShotAnimation.java | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/gfx/animations/ShotAnimation.java b/core/src/ch/asynk/tankontank/engine/gfx/animations/ShotAnimation.java index 9d2257e..4a0130d 100644 --- a/core/src/ch/asynk/tankontank/engine/gfx/animations/ShotAnimation.java +++ b/core/src/ch/asynk/tankontank/engine/gfx/animations/ShotAnimation.java @@ -49,11 +49,14 @@ public class ShotAnimation implements Disposable, Animation, Pool.Poolable private static final float EXPLOSION_FRAME_DURATION = 0.05f; private static Random random = new Random(); - private static Sound shortShot; - private static Sound longShot; + private static Sound shotSnd; + private static Sound shotSndLong; + private static Sound explosionSnd; + private static Sound explosionSndLong; private static Sprites shot; private static Sprites explosion; - private static double longShotId; + private static double shotSndLongId; + private static double explosionSndLongId; private TextureRegion shotRegion; private float shot_a; @@ -96,24 +99,30 @@ public class ShotAnimation implements Disposable, Animation, Pool.Poolable return a; } - public static void init(Texture shot_texture, int scols, int srows, Texture explosion_texture, int ecols, int erows, Sound longSnd, Sound shortSnd) + public static void init(Texture shot_texture, int scols, int srows, Texture explosion_texture, int ecols, int erows, Sound ls, Sound ss, Sound le, Sound se) { - longShot = longSnd; - shortShot = shortSnd; + shotSndLong = ls; + shotSnd = ss; + explosionSndLong = le; + explosionSnd = se; shot = new Sprites(shot_texture, scols, srows); explosion = new Sprites(explosion_texture, ecols, erows); - longShotId = -1; + shotSndLongId = -1; + explosionSndLongId = -1; } public static void resetSound() { - longShotId = -1; + shotSndLongId = -1; + explosionSndLongId = -1; } public static void free() { - shortShot.dispose(); - longShot.dispose(); + shotSnd.dispose(); + shotSndLong.dispose(); + explosionSnd.dispose(); + explosionSndLong.dispose(); shot.texture.dispose(); explosion.texture.dispose(); } @@ -197,10 +206,10 @@ public class ShotAnimation implements Disposable, Animation, Pool.Poolable if (!fired) { fired = true; - if (longShotId == -1) - longShotId = longShot.play(volume); + if (shotSndLongId == -1) + shotSndLongId = shotSndLong.play(volume); else - shortShot.play(volume); + shotSnd.play(volume); } if (!hit && (elapsed < hit_time)) { @@ -213,8 +222,10 @@ public class ShotAnimation implements Disposable, Animation, Pool.Poolable if (!hit) { hit = true; - // TODO hit sound - shortShot.play(volume); + if (explosionSndLongId == -1) + explosionSndLongId = explosionSndLong.play(volume); + else + explosionSnd.play(volume); } if (elapsed < end_time) { |