I did this exact same code with one of my other classes, with a diffrent method name and diffrent images, and that works just fine. So, what is wrong with my code?
and my variables are:
And in my contructor, the code is the following:
the problem with my code is, that is doesn't execute, and is stuck with one image.
/** Denne metode laver animationen
* Hvis man ikke bevæger sig, executer den ikke
*/
public void animation()
{
String knap = Greenfoot.getKey();
{
if ()
{
if (getImage() == spredteBen)
{
setImage(samledeBen);
}
else
{
setImage(spredteBen);
}
}
}
}private GreenfootImage spredteBen = new GreenfootImage("Gå 1.png");
private GreenfootImage samledeBen = new GreenfootImage("Gå 2.png");setImage(spredteBen);

