forked from TechHead27/EW
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenu.java
More file actions
Latest commit
56 lines (52 loc) · 1.66 KB
/
Copy pathMainMenu.java
File metadata and controls
56 lines (52 loc) · 1.66 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
importgreenfoot.*;
/**
* Write a description of class MainMenu here.
*
* @author (your name)
* @version (a version number or a date)
*/
publicclassMainMenuextendsWorld
{
privatestaticfinalint[][] options = {{170, 96}, {170, 200}, {170, 304}};
privateArrowselector;
privateGreenfootSoundbgm;
privateMenuItemplay = newMenuItem("images/buttons/button_play.png");
privateMenuItemquit = newMenuItem("images/buttons/button_quit.png");;
privateMenuItemcredits = newMenuItem("images/buttons/button_credits.png");;
/**
* Constructor for objects of class MainMenu.
*
*/
publicMainMenu()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
selector = newArrow(options);
addObject(selector, 170, 96);
addObject(play, 300, 90);
addObject(quit, 300, 195);
addObject(credits, 300, 300);
bgm = newGreenfootSound("BGM/TitleScreen.mp3");
}
publicvoidact()
{
bgm.playLoop();
if (Greenfoot.isKeyDown("enter"))
{
switch (selector.getSelection())
{
case0: Greenfoot.setWorld(newForestMap1());
bgm.stop();
break;
case1: Greenfoot.stop();
bgm.stop();
break;
case2: Greenfoot.setWorld(newCredits("images/credits/credits1.png"));
bgm.stop();
break;
default://never get here
break;
}
}
}
}