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

2016/11/12

Mouse

FutureCoder FutureCoder

2016/11/12

#
I need to get my character to change image if mouse is pressed and need to get another character to do something if the mouse clicks on it, how do i do this
Super_Hippo Super_Hippo

2016/11/12

#
Check the Greenfoot API (click here). Example:
//in act method
if (Greenfoot.mousePressed(this))
{
    //do "something"
}
FutureCoder FutureCoder

2016/11/12

#
thanks, it works for when i click on actor, but how do i make it so it does something if it's just clicked,
Super_Hippo Super_Hippo

2016/11/12

#
You can use 'null' instead of 'this'. Then it will execute when the mouse is clicked no matter if on an actor or not.
FutureCoder FutureCoder

2016/11/12

#
thanks, this helps alot
You need to login to post a reply.