So I am having trouble getting
which is in the method stopped()
to be called from
in the constructor of the class
Full Code:
song.stop();
GreenfootSound song = new GreenfootSound(sound);
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Number here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Number extends Actor
{
int arrayposition;
String value;
public String sound;
public Number(int position, String value, String soundFile)
{
arrayposition = position;
this.value = value;
sound = soundFile;
//GreenfootSound song = new GreenfootSound("soundFile");
}
/**
* Act - do whatever the Number wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
}
public void startSong()
{
int i =0;
while (i <1)
{
play();
i=i+1;
//Greenfoot.delay(30);
//Greenfoot.stop();
System.out.println("a");
}
}
public void stopSong()
{
int i =0;
while (i <1)
{
//song.stop();
stopped();
i=i+1;
//Greenfoot.delay(30);
//Greenfoot.stop();
System.out.println("b");
}
}
public void play()
{
//GreenfootSound song = new GreenfootSound(sound);
Greenfoot.playSound(sound);
}
public void stopped()
{
//GreenfootSound song = new GreenfootSound(sound);
song.stop();
}
}
