-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMainMenu.js
More file actions
134 lines (116 loc) · 4.14 KB
/
MainMenu.js
File metadata and controls
134 lines (116 loc) · 4.14 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
export default class MainMenu extends Phaser.Scene
{
constructor ()
{
super('MainMenu');
this.music;
this.state = "main";
}
create ()
{
let background = this.add.image(400, 300, 'background');
background.setScale(1.5,1.5);
this.tweens.add({
targets: background,
alpha: { from: 0, to: 1 },
duration: 1000
});
const fontStyle = {
fontFamily: 'Arial',
fontSize: 48,
color: '#ffffff',
fontStyle: 'bold',
padding: 16,
shadow: {
color: '#000000',
fill: true,
offsetX: 2,
offsetY: 2,
blur: 4
}
};
const miniFontStyle = {
fontFamily: 'Arial',
fontSize: 24,
color: '#ffffff',
fontStyle: 'bold',
padding: 16,
shadow: {
color: '#000000',
fill: true,
offsetX: 2,
offsetY: 2,
blur: 4
}
};
this.text1 = this.add.text(240, -20, 'Shape Shop', fontStyle);
this.text2 = this.add.text(120, 2000, 'Use Boolean logic to choose the right shapes!', miniFontStyle);
let frames = this.textures.get('shapes').getFrameNames();
for (let i = 0; i < 25; i++ ){
frames.pop();
}
this.im1 = this.add.sprite(-20,-20, 'shapes').setScale(0.8)
this.im1.setFrame(Phaser.Utils.Array.GetRandom(frames));
this.im2 = this.add.sprite(this.game.canvas.width + 40,40, 'shapes').setScale(0.8)
this.im2.setFrame(Phaser.Utils.Array.GetRandom(frames));
this.im3 = this.add.sprite(-20,this.game.canvas.height +40, 'shapes').setScale(0.8)
this.im3.setFrame(Phaser.Utils.Array.GetRandom(frames));
this.im4 = this.add.sprite(-20,this.game.canvas.height +40, 'shapes').setScale(0.8)
this.im4.setFrame(Phaser.Utils.Array.GetRandom(frames));
this.tweens.add({
targets: this.text1,
duration: 2000,
y: {start: 0, to: this.game.canvas.height/2 - this.text1.height},
ease: 'bounce.out',
});
this.tweens.add({
targets: this.text2,
duration: 2000,
y: {start: this.game.canvas.height + 100, to: this.game.canvas.height/2 + 200},
ease: 'bounce.out',
});
this.tweens.add({
targets: this.im1,
duration: 2000,
y: {start: 0, to: this.game.canvas.height/4},
x: {start: 0, to:this.game.canvas.width/4},
ease: 'bounce.out',
});
this.tweens.add({
targets: this.im2,
duration: 2000,
y: {start: this.game.canvas.height + 40, to: this.game.canvas.height/1.5},
x: {start: this.game.canvas.width + 40, to:this.game.canvas.width/1.35},
ease: 'bounce.out',
});
this.tweens.add({
targets: this.im3,
duration: 2000,
y: {start: -20, to: this.game.canvas.height/4},
x: {start: this.game.canvas.width + 40, to:this.game.canvas.width/1.35},
ease: 'bounce.out',
});
this.tweens.add({
targets: this.im4,
duration: 2000,
y: {start: this.game.canvas.width + 40, to: this.game.canvas.height/1.5},
x: {start: -20, to:this.game.canvas.width/4},
ease: 'bounce.out',
});
this.input.once('pointerdown', () => {
this.state = "intro";
let background2 = this.add.image(400, 300, 'background');
background2.setScale(1.5,1.5);
let intro = this.add.image(400,300, 'intro');
this.tweens.add({
targets: intro,
alpha: { from: 0, to: 1 },
duration: 100
});
this.input.once('pointerdown', () => {
this.state = "game";
this.scene.start('LevelSelect', {colorblind: false});
})
});
}
}