I'm not sure why I'm getting this error for assigning the up and down image to image 1 and 2? I'm trying to allow the key class to show black or white keys... I'm not having much luck. Help?
import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot)
public class Key extends Actor
{
private boolean isDown;
private String key;
private String sound;
private String upImage;
private String downImage;
/**
* Create a new key.
*/
public Key (String keyName, String soundFile)
{
key = keyName;
sound = soundFile;
upImage = image1;
downImage = image2;
setImage(upImage);
isDown = false;
}
/**
* Do the action for this key.
*/
public void act()
{
if ( !isDown && Greenfoot.isKeyDown(key)){
play();
setImage (downImage);
isDown = true;
}
if (isDown && !Greenfoot.isKeyDown(key)){
setImage (upImage);
isDown = false;
}
}
/**
* Play the note of this key.
*/
public void play()
{
Greenfoot.playSound(sound);
}
}
Thanks,
Sophie