From 655e19401debae60e029a4ceca41caeb52a80ad3 Mon Sep 17 00:00:00 2001 From: Jérémy Zurcher Date: Thu, 27 Nov 2014 15:35:48 +0100 Subject: ShotAnimation: use explosion sounds --- .../engine/gfx/animations/ShotAnimation.java | 41 ++++++++++++++-------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'core/src/ch/asynk/tankontank/engine/gfx') 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 9d2257e7..4a0130d0 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) { -- cgit v1.2.3