-
Notifications
You must be signed in to change notification settings - Fork 0
/
Back.java
34 lines (34 loc) · 966 Bytes
/
Back.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
32
33
34
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* This Class is for Back Button in Main Menu GUI.
*
* @Pyrozen
* @version (a version number or a date)
*/
public class Back extends Button
{
GreenfootSound effect = new GreenfootSound("Back Effect.mp3");
public void act()
{
// Add your action code here
MouseInfo mouse = Greenfoot.getMouseInfo();
if (mouse != null)
{
setImage("BackButton CLR.png");
List objects = getWorld().getObjectsAt(mouse.getX(), mouse.getY(), Button.class);
for (Object object : objects)
{
if (object == this)
{
setImage("BackButton PSRD.png");
}
}
}
if(Greenfoot.mouseClicked(this))
{
effect.play();
Greenfoot.setWorld(new MyWorld());
}
}
}