This site requires JavaScript, please enable it in your browser!
Greenfoot back
Sbaliyev
Sbaliyev wrote ...

2014/6/15

Image change

Sbaliyev Sbaliyev

2014/6/15

#
Yo guys, Iam new with Greenfoot and Iam currently working on a project. So the thing is, I want that my currently image changes when I hover it. I have this:
public class Locatie extends Actor
{
    private boolean onThis = false;  
    
    public void act() 
    {
        if(Greenfoot.mouseMoved(null)){
            onThis = Greenfoot.mouseMoved(this);  
        }
            if(onThis)  {
                setImage("locatieZwart.png");  
            }
            else  {
                setImage("locatieRood.png");   
            }
    }    
}
When I compile it, it doesnt give errors. But when i run it and hover the image, it says cant find "locatieRood.png" Could you guys please help me? Cheers,
CooliMC CooliMC

2014/6/15

#
You must put your locatieRood.png in the image folder of you project and the names of both must be the same that means that the immage in the imagefolder of you project should be named locatieRood.png and it must be a .png Hope i could help you :D
Sbaliyev Sbaliyev

2014/6/15

#
Yeah!! Thanks! Seriously that was such a stupid-beginners-problem -.-"
CooliMC CooliMC

2014/6/15

#
no problem therefor im here :D all of us started like you :D
You need to login to post a reply.