Added event for playing sound on button press.

This commit is contained in:
lieght
2025-10-02 12:40:57 +02:00
parent fb0e16acc2
commit e7fded0c9e
4 changed files with 9 additions and 2 deletions

Binary file not shown.

View File

@@ -36,7 +36,14 @@ public class SoundManager {
.listen(this::handlePlaySound)
.listen(this::handleStopSound)
.listen(this::handleMusicStart)
.listen(this::handleVolumeChange);
.listen(this::handleVolumeChange)
.listen(AudioEvents.playOnClickButton.class, _ -> {
try {
playSound("hitsound0.wav", false);
} catch (UnsupportedAudioFileException | LineUnavailableException | IOException e) {
throw new RuntimeException(e);
}
});
}
private void handlePlaySound(AudioEvents.PlayAudio event) {

View File

@@ -13,5 +13,5 @@ public class AudioEvents extends EventsBase {
public record StartBackgroundMusic() implements EventWithoutSnowflake {}
public record ChangeVolume(double newVolume) implements EventWithoutSnowflake {}
public record playOnClickButton() implements EventWithoutSnowflake {}
}