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

2014/9/16

My music wont play!

coder04 coder04

2014/9/16

#
can u fix my code
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)  
/** 
 * Write a description of class sdf here. 
 *  
 * @author (your name)  
 * @version (a version number or a date) 
 */  
public class Music extends Actor  
{  
    GreenfootSound music = new GreenfootSound("Virtualriots.mp3");    
    /** 
     * Act - do whatever the sdf wants to do. This method is called whenever 
     * the 'Act' or 'Run' button gets pressed in the environment. 
     */  
    public void act()   
    {      

        if(!music.isPlaying())    
        {    
            music.playLoop();    

        }    
        else
        { 
            music.stop();
        }
    }      
} 
danpost danpost

2014/9/16

#
Remove the 'else' block.
coder04 coder04

2014/9/16

#
still doesnt work
danpost danpost

2014/9/16

#
Show world class code where you add a Music actor into it.
You need to login to post a reply.