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

2012/12/12

Mouse Clicked from World

Barador Barador

2012/12/12

#
Hi In my game I have an Object placed in my World. When I click on it it has to do something with the world, so I want to put the code in my world. I have this:
if(Greenfoot.mouseClicked(Exit.class))
            {
                //to do
            }
But if I click on the object nothing happens. Can you help me?
danpost danpost

2012/12/12

#
The method 'mouseClicked' in the Greenfoot class takes an Object as a parameter, not a Class.
Barador Barador

2012/12/12

#
Ok now I moved this to the object. There I have to use
Greenfoot.mouseClicked(this)
Right?
danpost danpost

2012/12/12

#
The keyworld 'this' refers to an Object class object , so that would be one way to use it (if you want it to check for clicks on the current object whose method is being executed on).
You need to login to post a reply.