-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRollDiceBouton.java
More file actions
executable file
·40 lines (32 loc) · 964 Bytes
/
RollDiceBouton.java
File metadata and controls
executable file
·40 lines (32 loc) · 964 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
30
31
32
33
34
35
36
37
38
39
40
import greenfoot.Greenfoot;
/**
* Classe RollDiceBouton. Bouton "Lancer les dés".
*
* @author (Emeric de Bernis)
*/
public class RollDiceBouton extends Bouton {
private boolean isClickable;
// Initialise les attributs, charge l'image du bouton, crée le bouton.
public RollDiceBouton(Backgammon world, int X, int Y) {
super(world, X, Y);
this.setImage("images/rolldice.png");
this.isClickable = true;
}
public void act() {
// Change l'image lors du clic sur le bouton
if (Greenfoot.mousePressed(this) && this.isClickable) {
this.setImage("images/rolldicemouseover.png");
}
// Lance les dés
if (Greenfoot.mouseClicked(this) && this.isClickable) {
this.setImage("images/rolldice.png");
this.world.getManager().rollTheDice();
}
}
public boolean isClickable() {
return isClickable;
}
public void setClickable(boolean isClickable) {
this.isClickable = isClickable;
}
}