diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2018-11-24 10:16:45 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2018-11-24 10:16:45 +0100 |
commit | ba2bda08d58646685538a62f1ddfa044e99bbc19 (patch) | |
tree | e796c263589f0ddf3f4ce6a344369682f97e17b3 /test/src/ch/asynk/gdx/boardgame | |
parent | 01971d7f6b332cfd1bbfeec017701a129d9ce3f1 (diff) | |
download | gdx-boardgame-ba2bda08d58646685538a62f1ddfa044e99bbc19.zip gdx-boardgame-ba2bda08d58646685538a62f1ddfa044e99bbc19.tar.gz |
Dice : add roll sound
Diffstat (limited to 'test/src/ch/asynk/gdx/boardgame')
-rw-r--r-- | test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java | 3 | ||||
-rw-r--r-- | test/src/ch/asynk/gdx/boardgame/test/Assets.java | 32 | ||||
-rw-r--r-- | test/src/ch/asynk/gdx/boardgame/test/Dice.java | 8 |
3 files changed, 25 insertions, 18 deletions
diff --git a/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java b/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java index 92791d0..372a406 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java @@ -91,7 +91,8 @@ public class AnimationsScreen extends AbstractScreen private Dice getDice(final GdxBoardTest app, int col, int row, int side) { - Dice d = new Dice(app.assets.getTexture(app.assets.DICE), 9, 16, 0.1f); + Dice d = new Dice(app.assets.getTexture(app.assets.DICE), 9, 16, 0.02f, + app.assets.getSound(app.assets.DICE_SND)); Vector2 v = new Vector2(); this.board.centerOf(col, row, v); d.centerOn(v.x, v.y); diff --git a/test/src/ch/asynk/gdx/boardgame/test/Assets.java b/test/src/ch/asynk/gdx/boardgame/test/Assets.java index 1ffece3..deda5b7 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/Assets.java +++ b/test/src/ch/asynk/gdx/boardgame/test/Assets.java @@ -15,22 +15,22 @@ public class Assets extends ch.asynk.gdx.boardgame.Assets { public static final String LOADING = "loading.atlas"; - public static final String CORNER = "corner.png"; - public static final String MAP_00 = "map_00.png"; - public static final String CHESS = "chess.jpg"; - public static final String TRI = "triangle.png"; - public static final String FONT = "veteran-typewriter.ttf"; - public static final String FONT_20 = "size20.ttf"; - public static final String FONT_25 = "size25.ttf"; - public static final String PATCH = "ui-patch.png"; - public static final String PANZER = "panzer.png"; - public static final String HEX_OVERLAYS = "hex-overlays.atlas"; - public static final String SHELL_FIRE = "shell_fire.png"; - public static final String SHELL_FIRE_SND = "shell_fire.ogg"; - public static final String EXPLOSIONS = "explosions.png"; - public static final String EXPLOSION_SND = "explosion.ogg"; - public static final String DICE = "dice.png"; - public static final String DICE_SND = "dice.ogg"; + public static final String CORNER = "corner.png"; + public static final String MAP_00 = "map_00.png"; + public static final String CHESS = "chess.jpg"; + public static final String TRI = "triangle.png"; + public static final String FONT = "veteran-typewriter.ttf"; + public static final String FONT_20 = "size20.ttf"; + public static final String FONT_25 = "size25.ttf"; + public static final String PATCH = "ui-patch.png"; + public static final String PANZER = "panzer.png"; + public static final String HEX_OVERLAYS = "hex-overlays.atlas"; + public static final String SHELL_FIRE = "shell_fire.png"; + public static final String SHELL_FIRE_SND = "shell_fire.ogg"; + public static final String EXPLOSIONS = "explosions.png"; + public static final String EXPLOSION_SND = "explosion.ogg"; + public static final String DICE = "dice.png"; + public static final String DICE_SND = "dice.ogg"; private final FreeTypeFontLoaderParameter params20; private final FreeTypeFontLoaderParameter params25; diff --git a/test/src/ch/asynk/gdx/boardgame/test/Dice.java b/test/src/ch/asynk/gdx/boardgame/test/Dice.java index b0640a5..eeb0a2d 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/Dice.java +++ b/test/src/ch/asynk/gdx/boardgame/test/Dice.java @@ -1,5 +1,6 @@ package ch.asynk.gdx.boardgame.test; +import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.Texture; import ch.asynk.gdx.boardgame.FramedSprite; @@ -22,12 +23,14 @@ public class Dice extends FramedSprite implements Drawable, Animation private int last; private float dt; private float elapsed; + private Sound snd; - public Dice(Texture texture, int rows, int cols, float dt) + public Dice(Texture texture, int rows, int cols, float dt, Sound snd) { super(texture, rows, cols); this.roll = null; this.dt = dt; + this.snd = snd; } public void setSide(int i) @@ -48,6 +51,9 @@ public class Dice extends FramedSprite implements Drawable, Animation last = roll.length - 1; elapsed = 0f; setFrame(roll[x]); + if (snd != null) { + snd.play(); + } } @Override public void dispose() { } |