fixed bug when playing rocket audio to not produce an AudioRender error
This commit is contained in:
parent
9e591e37c3
commit
f8e97266d5
@@ -83,10 +83,10 @@ public void setEnabled(boolean enabled) {
|
|||||||
public void initialize(AppStateManager stateManager, Application app) {
|
public void initialize(AppStateManager stateManager, Application app) {
|
||||||
super.initialize(stateManager, app);
|
super.initialize(stateManager, app);
|
||||||
this.app = (BattleshipApp) app;
|
this.app = (BattleshipApp) app;
|
||||||
shipDestroyedSound = loadSound(app, "Sound/Effects/sunken.wav", 1); //NON-NLS
|
shipDestroyedSound = loadSound(app, "Sound/Effects/sunken.wav"); //NON-NLS
|
||||||
splashSound = loadSound(app, "Sound/Effects/splash.wav", 2); //NON-NLS
|
splashSound = loadSound(app, "Sound/Effects/splash.wav"); //NON-NLS
|
||||||
explosionSound = loadSound(app, "Sound/Effects/explosion.wav",3); //NON-NLS
|
explosionSound = loadSound(app, "Sound/Effects/explosion.wav"); //NON-NLS
|
||||||
rocketSound = loadSound(app, "Sound/Effects/rocket.wav",4);
|
rocketSound = loadSound(app, "Sound/Effects/rocket.wav");
|
||||||
|
|
||||||
volume = PREFERENCES.getFloat(SOUND_VOLUME_PREF, 1.0f);
|
volume = PREFERENCES.getFloat(SOUND_VOLUME_PREF, 1.0f);
|
||||||
}
|
}
|
||||||
@@ -98,12 +98,11 @@ public void initialize(AppStateManager stateManager, Application app) {
|
|||||||
* @param name The name of the sound file.
|
* @param name The name of the sound file.
|
||||||
* @return The loaded AudioNode.
|
* @return The loaded AudioNode.
|
||||||
*/
|
*/
|
||||||
private AudioNode loadSound(Application app, String name, int channel) {
|
private AudioNode loadSound(Application app, String name) {
|
||||||
try {
|
try {
|
||||||
final AudioNode sound = new AudioNode(app.getAssetManager(), name, AudioData.DataType.Buffer);
|
final AudioNode sound = new AudioNode(app.getAssetManager(), name, AudioData.DataType.Buffer);
|
||||||
sound.setLooping(false);
|
sound.setLooping(false);
|
||||||
sound.setPositional(false);
|
sound.setPositional(false);
|
||||||
sound.setChannel(channel);
|
|
||||||
return sound;
|
return sound;
|
||||||
}
|
}
|
||||||
catch (AssetLoadException | AssetNotFoundException ex) {
|
catch (AssetLoadException | AssetNotFoundException ex) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package pp.battleship.game.client;
|
package pp.battleship.game.client;
|
||||||
|
|
||||||
import pp.battleship.message.client.AnimationEndMessage;
|
|
||||||
import pp.battleship.message.server.EffectMessage;
|
import pp.battleship.message.server.EffectMessage;
|
||||||
import pp.battleship.message.server.SwitchBattleState;
|
import pp.battleship.message.server.SwitchBattleState;
|
||||||
import pp.battleship.model.IntPoint;
|
import pp.battleship.model.IntPoint;
|
||||||
@@ -9,7 +8,7 @@
|
|||||||
import pp.battleship.notification.Music;
|
import pp.battleship.notification.Music;
|
||||||
import pp.battleship.notification.Sound;
|
import pp.battleship.notification.Sound;
|
||||||
|
|
||||||
public class AnimatonState extends ClientState {
|
public class AnimationState extends ClientState {
|
||||||
private boolean myTurn;
|
private boolean myTurn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,15 +18,15 @@ public class AnimatonState extends ClientState {
|
|||||||
* @param myTurn a boolean containing if it is the clients turn
|
* @param myTurn a boolean containing if it is the clients turn
|
||||||
* @param position the position a shell should be created
|
* @param position the position a shell should be created
|
||||||
*/
|
*/
|
||||||
public AnimatonState(ClientGameLogic logic, boolean myTurn, IntPoint position) {
|
public AnimationState(ClientGameLogic logic, boolean myTurn, IntPoint position) {
|
||||||
super(logic);
|
super(logic);
|
||||||
logic.playMusic(Music.BATTLE_THEME);
|
logic.playMusic(Music.BATTLE_THEME);
|
||||||
logic.playSound(Sound.ROCKET_FIRED);
|
|
||||||
this.myTurn = myTurn;
|
this.myTurn = myTurn;
|
||||||
if(myTurn) {
|
if(myTurn) {
|
||||||
logic.getOpponentMap().add(new Shell(position));
|
logic.getOpponentMap().add(new Shell(position));
|
||||||
}else {
|
}else {
|
||||||
logic.getOwnMap().add(new Shell(position));
|
logic.getOwnMap().add(new Shell(position));
|
||||||
|
logic.playSound(Sound.ROCKET_FIRED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9,13 +9,8 @@
|
|||||||
|
|
||||||
import pp.battleship.message.client.ShootMessage;
|
import pp.battleship.message.client.ShootMessage;
|
||||||
import pp.battleship.message.server.AnimationStartMessage;
|
import pp.battleship.message.server.AnimationStartMessage;
|
||||||
import pp.battleship.message.server.EffectMessage;
|
|
||||||
import pp.battleship.model.IntPoint;
|
import pp.battleship.model.IntPoint;
|
||||||
import pp.battleship.model.ShipMap;
|
|
||||||
import pp.battleship.notification.Music;
|
import pp.battleship.notification.Music;
|
||||||
import pp.battleship.notification.Sound;
|
|
||||||
|
|
||||||
import java.lang.System.Logger.Level;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the state of the client where players take turns to attack each other's ships.
|
* Represents the state of the client where players take turns to attack each other's ships.
|
||||||
@@ -55,6 +50,6 @@ else if (logic.getOpponentMap().isValid(pos))
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receivedAnimationStart(AnimationStartMessage msg){
|
public void receivedAnimationStart(AnimationStartMessage msg){
|
||||||
logic.setState(new AnimatonState(logic, msg.isMyTurn(), msg.getPosition()));
|
logic.setState(new AnimationState(logic, msg.isMyTurn(), msg.getPosition()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user