Hi, I am working on my game and was wondering how to give points when an object is clicked by the mouse/cursor.


1 2 | Greenfoot.mouseClicked( this ); //this is if you put it in the object that's to be clicked on Greenfoot.mouseClicked(Object obj); //this is if you put it elsewhere (such as in the world class). over here my class is named object but that's arbitrary. |
1 | true ; // or false; |
1 | if (Greenfoot.mouseClicked( this )) { << increment score here >> } |
1 | if (Greenfoot.mouseClicked( this )) { 1 } |
1 | if (Greenfoot.mouseClicked( this )) {<< 1 >>} |
1 2 3 4 | if (Greenfoot.mouseClicked( this )) { score++; } |
1 | ((MyWorld)getWorld()).getScore().add( 1 ); |