-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuit.java
More file actions
28 lines (24 loc) · 796 Bytes
/
Quit.java
File metadata and controls
28 lines (24 loc) · 796 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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Used when exiting the game.
*/
public class Quit extends Actor {
private int x;
private int y;
public void act() {
MouseInfo mouse = Greenfoot.getMouseInfo();
if (mouse != null) {
x = mouse.getX();
y = mouse.getY();
if (Greenfoot.mouseClicked(null)) {
if (x > 140 && x < 220 && y > 320 && y < 360) {
getWorld().removeObject(this);
SoundManager.soundMenu.stop();
Greenfoot.stop();
} else if (x > 325 && x < 405 && y > 320 && y < 360) {
getWorld().removeObject(this);
}
}
}
}
}