-
Notifications
You must be signed in to change notification settings - Fork 0
/
GreenLight.java
39 lines (39 loc) · 1.03 KB
/
GreenLight.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
35
36
37
38
39
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* Write a description of class GreenLight here.
*
* @Pyrozen (your name)
* @version (a version number or a date)
*/
public class GreenLight extends Button
{
int check = 0;
GreenfootSound effect = new GreenfootSound("Button Effect.mp3");
public void act()
{
MouseInfo mouse = Greenfoot.getMouseInfo();
if(mouse != null)
{
setImage("GreenLightMode CLR.png");
List objects = getWorld().getObjectsAt(mouse.getX(), mouse.getY(), Button.class);
for (Object object : objects)
{
if (object == this)
{
setImage("GreenLightMode PSRD.png");
}
}
}
if(Greenfoot.mouseClicked(this))
{
effect.play();
check = 1;
Greenfoot.setWorld(new Playfield());
}
}
public int getCheck()
{
return check;
}
}