-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.ts
40 lines (30 loc) · 1.1 KB
/
menu.ts
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
namespace Menu {
let _callback: () => void
let _choiceSprite: Sprite
let _versionSprite: Sprite
function startGame() {
scene.setBackgroundImage(assets.image`empty`)
controller.player1.A.removeEventListener(ControllerButtonEvent.Pressed, startGame)
_choiceSprite.destroy()
music.stopAllSounds()
_versionSprite.destroy()
_callback()
}
export function init() {
scene.setBackgroundImage(assets.image`Splash Screen`)
_choiceSprite = textsprite.create('Arrrgh Be Greedy!', 0, 15)
_choiceSprite.x = 80
_choiceSprite.y = 100
// Version information
_versionSprite = textsprite.create(version, 0, 9)
_versionSprite.x = 140
_versionSprite.y = 115
music.stopAllSounds()
PirateLives.hide()
music.play(music.createSong(assets.song`Title`), music.PlaybackMode.LoopingInBackground)
controller.player1.A.addEventListener(ControllerButtonEvent.Pressed, startGame)
}
export function onStartGame(callback: () => void) {
_callback = callback
}
}