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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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 ); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 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 } } } |