-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDummyImage.java
More file actions
72 lines (63 loc) · 1.67 KB
/
DummyImage.java
File metadata and controls
72 lines (63 loc) · 1.67 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Main class for dummy buttons
* buttons that dont do anything, just show stuff when the user hover overs
*
* @author James Lu
* @version 1.0
*/
public class DummyImage extends Actor implements HoverInfo
{
protected Map map;
protected GreenfootImage bg;
protected int hoverCounter;
protected boolean selected;
public DummyImage(){
hoverCounter = 0;
}
protected void addedToWorld(World world){
map = (Map) world;
}
public void act(){
if (hoverCounter >= 50){
map.hm.setData (this);
int[] co = setCo();
map.addObject (map.hm, co[0], co[1]);
}
this.setImage (bg);
}
/**
* Sets the coorinates of the hovermenu
*/
protected int[] setCo(){
int[] coordinates = new int[2];
int tempX = this.getX();
int tempY = this.getY();
if (tempX < 600){
coordinates[0] = tempX + 200;
}else{
coordinates[0] = tempX - 150;
}
coordinates[1] = tempY - map.hm.getHeight()/2;
return coordinates;
}
/** interface methods */
/**
* Increases the hover counter when the mouse hovers over this object
*/
public void hoverOver(){
hoverCounter++;
}
/**
* Changes the image to be selected or not Pass true if the button is selected
*/
public void changeImg(boolean s){
selected = s;
}
/**
* Resets the hover counter when the mouse is no longer hovering over it
*/
public void resetCounter(){
hoverCounter = 0;
}
}