I am working on a basic MP3 player that uses a volume down & volume up button. I have been able to get the volume to increase but it only increases more when I use the "-" instead of "+". Any assistance would be appreciated.
below is Myworld which extends World
The following is my VolDown code:
public MyWorld()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(300, 75, 1);
setup();
}
private void setup()
{
musik = new GreenfootSound("California.wav");
Start play = new Start(musik);
addObject(play,35,37);
VolUp volumeUp = new VolUp(musik);
addObject(volumeUp,120,37);
VolDown volumeDown = new VolDown(musik);
addObject(volumeDown,200,37);
Volume volume = new Volume(musik);
addObject(volume, 260, 45);
Message msg = new Message(text);
addObject(msg, 260, 15);
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class VolDown here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class VolDown extends Actor
{
private GreenfootSound music;
/**
* Act - do whatever the VolumeUp wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public VolDown (GreenfootSound musik)
{
this.music = musik;
}
public void act()
{
isClicked();
}
public void isClicked()
{
if(Greenfoot.mouseClicked(this))
{
//System.out.print(music.getVolume() + " initVolDn \n"); //Testing only
music.setVolume(music.getVolume()-10);
//System.out.print(music.getVolume() + " VolDn \n"); //Testing only
}
}
}
