I have this piece of code that should be quite logical but Greenfoot won't recognize that the image is the same:
Here's what the console shows :
I've alredy try to make a getImage().toString().equalsIgnoreCase but it didn't work either...
Thank you for your time
private GreenfootImage[] images = {new GreenfootImage("chestBleu.png"), new GreenfootImage("chestBleuOpen.png")};
public void act()
{
if( this.isTouching(Player.class) && Greenfoot.mousePressed(this))
{
System.out.println(this.getImage().toString() + " vs " + images[0].toString());
if (this.getImage() == images[0])
{
System.out.println("correct");
setImage(images[1]);
//...
}
else {
System.out.println("why this?");
//...
}
}
}
}
Image file name: chestBleu.png Image url: [...] vs Image file name: chestBleu.png Image url: [same as the other one] why this?

