-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModeSelector.java
31 lines (26 loc) · 928 Bytes
/
ModeSelector.java
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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class ModeSelector extends Actor {
private int type;
private boolean state;
private String label;
public ModeSelector(boolean state, String label, int type) {
MyWorld world = (MyWorld) getWorld();
this.state = state;
this.label = label;
this.type = type;
this.setImage(DrawingUtil.drawButton(state, label));
}
public void reset() {
this.state = false;
this.setImage(DrawingUtil.drawButton(state, label));
}
public void act() {
if(Greenfoot.mouseClicked(this)) {
MyWorld world = (MyWorld) getWorld();
//if(world.type == this.type) return;
world.cancelOldMode(this.type);
this.state = true;
this.setImage(DrawingUtil.drawButton(state, label));
}
}
}