made music and sfx volume adjustable
This commit is contained in:
@@ -8,6 +8,7 @@ import de.miaurizius.jgame2d.tile.TileManager;
|
||||
import de.miaurizius.jgame2d.tile.interactive.InteractiveTile;
|
||||
|
||||
import javax.sound.sampled.Clip;
|
||||
import javax.sound.sampled.FloatControl;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -50,7 +51,7 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
public UI ui = new UI(this);
|
||||
public EventHandler eventH = new EventHandler(this);
|
||||
public Sound se = new Sound();
|
||||
Sound music = new Sound();
|
||||
public Sound music = new Sound();
|
||||
Thread gameThread;
|
||||
|
||||
// ENTITY AND OBJECT
|
||||
@@ -197,7 +198,9 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
|
||||
// MUSIC
|
||||
public void playMusic(int i) {
|
||||
Clip c = se.clips[i];
|
||||
Clip c = music.clips[i];
|
||||
music.fc = (FloatControl) c.getControl(FloatControl.Type.MASTER_GAIN);
|
||||
music.checkVolume();
|
||||
if(c.isRunning()) c.stop();
|
||||
c.setFramePosition(0);
|
||||
c.start();
|
||||
@@ -208,6 +211,8 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
}
|
||||
public void playSE(int i) {
|
||||
Clip c = se.clips[i];
|
||||
se.fc = (FloatControl) c.getControl(FloatControl.Type.MASTER_GAIN);
|
||||
se.checkVolume();
|
||||
if(c.isRunning()) c.stop();
|
||||
c.setFramePosition(0);
|
||||
c.start();
|
||||
|
||||
Reference in New Issue
Block a user