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

2014/9/16

My song will not work can fix my code

coder04 coder04

2014/9/16

#
The song is echoie
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
{
    /**
     * 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() 
    {
    GreenfootSound music = new GreenfootSound("Virtualriots.mp3");  
  
    if(!music.isPlaying())  
    {  
         music.play();  
    }  
    }    
}
Super_Hippo Super_Hippo

2014/9/16

#
You create a new GreenfootSound object every act cycle. Of course this new sound doesn't play, so every act cycle another sound starts to play. Put line 17 to line 11 or so.
You need to login to post a reply.