-
Notifications
You must be signed in to change notification settings - Fork 2
/
MainMenu.js
executable file
·50 lines (43 loc) · 1.65 KB
/
MainMenu.js
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
game.module('game.main').body(function() {
game.addAsset('background/background menu.jpg', 'background1'); //Including backgound and sound
game.addAudio('sounds/collision1.ogg', 'collision1');
game.createScene('Main', {
init: function() {
this.levelSel = 1;
//Background
var background = new game.Sprite('background1').center().addTo(this.stage);
//Adding Text
var style = {font:'bold 30px sans-serif', fill: 'rgb(64, 128, 255)', stroke: 'rgb(0, 0, 64)', strokeThickness: 6};
this.title = new game.Text('', style).addTo(this.stage);
this.title.x = 100; this.title.y = 800;
this.printLevel();
//this.help = new game.Text('Use Arrow keys and ENTER', style).addTo(this.stage);
//this.help.x = 10; this.help.y = 600 - 24 - 10;
},
keydown: function(event) {
if(event == "UP")
this.levelSel++;
if(event == "DOWN")
this.levelSel--;
this.levelSel = (this.levelSel + levelNames.length) % levelNames.length;
//Textausgabe
this.printLevel();
//Anwenden
if(event == "ENTER")
this.runLevel();
//sounds
//var sound = game.audio.playSound('collision1');
//game.audio.setVolume(sound, 0.5);
},
printLevel: function()
{
this.title.setText('Ausgewählter Level: ' + ' '+ levelNames[this.levelSel]);
},
runLevel: function()
{
levelName = levelNames[this.levelSel];
console.log("Now playing " + levelName);
game.system.setScene("Game");
}
});
});