diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2018-11-22 16:17:34 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2018-11-22 16:17:34 +0100 |
commit | 9cbb7c7ba61c6f5d562ee81f13ba53d4aa6e9849 (patch) | |
tree | 05f5420e2d06d49e792cd7f6128b491660b9f562 | |
parent | 0519f5e216bebdc9ea3ebe75d053dac99e9e1d98 (diff) | |
download | gdx-boardgame-9cbb7c7ba61c6f5d562ee81f13ba53d4aa6e9849.zip gdx-boardgame-9cbb7c7ba61c6f5d562ee81f13ba53d4aa6e9849.tar.gz |
ShellFireAnimation : support fire and explosion sounds
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/animations/ShellFireAnimation.java | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/animations/ShellFireAnimation.java b/core/src/ch/asynk/gdx/boardgame/animations/ShellFireAnimation.java index e2f0f59..ee041e5 100644 --- a/core/src/ch/asynk/gdx/boardgame/animations/ShellFireAnimation.java +++ b/core/src/ch/asynk/gdx/boardgame/animations/ShellFireAnimation.java @@ -4,12 +4,13 @@ import java.util.Hashtable; import java.util.Map; import java.util.Random; -import com.badlogic.gdx.utils.Pool; +import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.MathUtils; +import com.badlogic.gdx.utils.Pool; import ch.asynk.gdx.boardgame.FramedSprite; import ch.asynk.gdx.boardgame.Piece; @@ -25,8 +26,12 @@ public class ShellFireAnimation extends TimedAnimation implements Pool.Poolable public float explosionDuration; public FramedSprite shellSprites; public FramedSprite explosionSprites; + public Sound shellFireSnd; + public Sound explosionSnd; public Config(float maxFireDelay, float maxShootScattering, float shellSpeed, - float smokeDuration, float explosionDuration, FramedSprite shellSprites, FramedSprite explosionSprites) + float smokeDuration, float explosionDuration, + FramedSprite shellSprites, FramedSprite explosionSprites, + Sound shellFireSnd, Sound explosionSnd) { this.maxFireDelay = maxFireDelay; this.maxShootScattering = maxShootScattering; @@ -35,6 +40,8 @@ public class ShellFireAnimation extends TimedAnimation implements Pool.Poolable this.explosionDuration = explosionDuration; this.shellSprites = shellSprites; this.explosionSprites = explosionSprites; + this.shellFireSnd = shellFireSnd; + this.explosionSnd = explosionSnd; } } @@ -47,12 +54,15 @@ public class ShellFireAnimation extends TimedAnimation implements Pool.Poolable float smokeDuration, float explosionDuration, final Texture shellTexture, int shellC, int shellR, - final Texture explosionTexture, int explosionC, int explosionR + final Texture explosionTexture, int explosionC, int explosionR, + final Sound shellFireSnd, + final Sound explosionSnd ) { Config cfg = new Config(maxFireDelay, maxShootScattering, shellSpeed, smokeDuration, explosionDuration, new FramedSprite(shellTexture, shellC, shellR), - new FramedSprite(explosionTexture, explosionC, explosionR) + new FramedSprite(explosionTexture, explosionC, explosionR), + shellFireSnd, explosionSnd ); configs.put(name, cfg); } @@ -198,6 +208,9 @@ public class ShellFireAnimation extends TimedAnimation implements Pool.Poolable if (!fired) { fired = true; drawFire = true; + if(cfg.shellFireSnd != null) { + cfg.shellFireSnd.play(); + } } if (!hit && (elapsed < hitTime)) { @@ -211,6 +224,9 @@ public class ShellFireAnimation extends TimedAnimation implements Pool.Poolable if (!hit) { hit = true; drawExplosion = true; + if(cfg.explosionSnd != null) { + cfg.explosionSnd.play(); + } } float dt = (elapsed - hitTime); |