-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClickableActor.java
More file actions
29 lines (26 loc) · 843 Bytes
/
ClickableActor.java
File metadata and controls
29 lines (26 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class ClickableActor here.
*
* @author (your name)
* @version (a version number or a date)
*/
public abstract class ClickableActor extends Actor
{
protected MouseInfo mouse;
/**
* Checks to see if the user is clicking the wombat
*/
public boolean isGettingClicked()
{
//We ask greenfoot for all available mouse information:
mouse = Greenfoot.getMouseInfo();
if(mouse != null)
{
//Is the mouse hovering over this actor AND is the primary button being clicked???
return (this == mouse.getActor() && mouse.getButton() == 1);
}
//If there is NO available mouse information we return false!!
return false;
}
}