This site requires JavaScript, please enable it in your browser!
Greenfoot back
ronald
ronald wrote ...

2021/2/7

Background Sound

ronald ronald

2021/2/7

#
public class Background extends World
{

    /**
     * Constructor for objects of class MyWorld.
     * 
     */
    
    static final Color TRANS = new Color(0, 0, 0, 0);
    
    Actor btn01,btn02,btn03;
    
    public Background()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(900, 600, 1); 
    
        addObject(btn01 = getNewButton("BUTTON 01"),200,100);
        addObject(btn02 = getNewButton("BUTTON 02"),200,150);
        addObject(btn03 = getNewButton("BUTTON 03"),200,200);
        
    }
    
    
    public void act()
    {
            
        
             if(Greenfoot.mouseClicked(btn01))
                        Greenfoot.playSound("01 - Moonlight.waw");
                        
             if(Greenfoot.mouseClicked(btn02))
                        Greenfoot.playSound("02 - Dangerous Woman.waw");
                        
             if(Greenfoot.mouseClicked(btn03))
                       Greenfoot.playSound("03 - Be Alright.waw");
                        
             
    }
        
    
    public Actor getNewButton(String caption) 
    {
        
     GreenfootImage base = new GreenfootImage(400,230);
     base.setColor(Color.BLUE);
     base.fillRect(100,100,200,30);
       
     GreenfootImage text = new GreenfootImage(caption, 24, Color.BLACK, TRANS);
     base.drawImage(text, 200-text.getWidth()/2, 115-text.getHeight()/2);
     base.setTransparency(128);
     
     Actor button = new Actor()
     {
         
         
     };
     button.setImage(base);
     return button;
        
    } 
}
I am creating a background music, I am using BGmusic Actor for this but when I compile a window opens and tells me that it cannot find any music files Thank you for your help
danpost danpost

2021/2/7

#
I do not know of any music file format with a ".waw" extension.
ronald ronald

2021/2/7

#
thank you well seen, I did not watch out
You need to login to post a reply.