hi, I am trying to do a guitar trainer project, I ran into the issue of trying to do a big method for all my subclasses.
so in my subclasses, I have
and I want to play tones with my superclass "guitar" which all of my keys extend.
my method looks like this:
neither one of these way work.
The tone that Greenfoot plays is currently the one inside the guitar class, which is not what I desired.
So how would I get the subclasses to inherit the method and play the tone that's inside the subclasses instead?
Also I have found that Greenfoot can't play the same sound file over and over again,
which means that if i keep playing a sound, it doesnt stop itself and start over instead waits for it to finish then start again, and when thats repeated serveral times, all the sounds stop.
Is there a way to implement a stop sound thing everytime I press a key then a new sound is played?
cheers kira
private static GreenfootSound tone = new GreenfootSound("4e.wav");
public void act()
{
checkKey("y");
} public void checkKey(String key)
{
GreenfootSound temp = this.getTone();
if(Greenfoot.mousePressed(this))
{
temp.play();
}
if(Greenfoot.isKeyDown(key))
{
temp.play();
}
}
public void checkKey(String fret, String key)
{
if(Greenfoot.mousePressed(this))
{
this.tone.play();
}
if(Greenfoot.isKeyDown(fret) && Greenfoot.isKeyDown(key))
{
this.tone.play();
}
}
