Hello, Greenfoot community :)
I have to hand something in tomorrow, and you are my last resort.
I think, for you, the problem is quite simple to solve, but because I'm a rookie, this isn't the case concerning myself.
So, I need to create a piano.
Till tomorrow, we need to have two working keys playing different sounds and were supposed to do that with strings.
I just can't get the hang of it...my two keys play the same sound, but I barely know anything, so I didn't experiment much.
Here is my code:
How will I get this to work?
Thanks in advance!
Night
public Key(String key, String sound)
{
isDown = false;
}
public void act()
{
play();
}
public void play()
{
if (Greenfoot.isKeyDown("t") && !isDown)
{
Greenfoot.playSound("2a.wav");
setImage("white-key-down.png");
isDown = true;
}
else if (isDown == true && !Greenfoot.isKeyDown("t"))
{
isDown = false;
setImage("white-key.png");
}
}
}


