Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
FogNetwork
GitHub Repository: FogNetwork/Tsunami
Path: blob/main/public/games/files/gopher-kart/js/stateTitle.js
1036 views
1
var StateTitle = {
2
preload: function(){
3
game.load.bitmapFont('pixelFont', 'assets/fonts/bitmapFonts/pixelFont.png', 'assets/fonts/bitmapFonts/pixelFont.xml');
4
game.load.audio("title", "assets/music/BeepBox-Song2-compressed.m4a");
5
game.load.image("city", "assets/city-re-colored.png");
6
game.load.audio("select_button", "assets/music/sfx/select.wav");
7
game.stage.backgroundColor = 0xe9fffe;
8
game.load.spritesheet("logo", "assets/menu-animation.png", 576, 334, 28);
9
//Need to add buttons for:
10
//1. Start game
11
//2. Tutorial??
12
game.load.spritesheet("buttons", "assets/main-menu-buttons.png", 217, 40, 2);
13
game.load.spritesheet("controls-buttons", "assets/controls-button.png", 108, 32, 2);
14
//Need: "best played in landscape-view image for mobile"
15
16
//Temp button for tutorial button
17
game.load.image("tutorial", "assets/try-again.png");
18
game.load.image("background", "assets/bg-color.png");
19
game.load.image("sky", "assets/clouds-re-colored.png");
20
game.load.image("mtn", "assets/mountains-recolored.png");
21
},
22
23
create: function (){
24
// game.scale.pageAlignHorizontally = true;
25
// game.scale.pageAlignVertically = true;
26
// game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
27
// game.stage.disableVisibilityChange = true;
28
29
background = game.add.tileSprite(0, 0, 600, 432, "background");
30
this.titleSong = game.add.audio("title");
31
this.titleSong.play('', 0, 1, true);
32
33
this.sky = game.add.tileSprite(0, 10, 600, 78, "sky");
34
this.mtn = game.add.tileSprite(0, 295, 600, 131, "mtn");
35
this.city = game.add.tileSprite(0, 342, 600, 90, "city");
36
37
this.logo = game.add.sprite(game.world.centerX, game.world.height-250, "logo");
38
this.logo.anchor.set(0.5, 0.5);
39
this.logo.animations.add("menu", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
40
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28], 12, true);
41
this.logo.animations.play("menu");
42
43
//Define and add game buttons
44
this.startBtn = game.add.button(285, game.world.height-60, "buttons", this.startGame, this, 1, 0, 1);
45
this.startBtn.anchor.set(0.5, 0.5);
46
47
//Define and add game buttons
48
this.tutorial = game.add.button(486, game.world.height-37, "controls-buttons", this.startTutorial, this, 1, 0, 1);
49
this.startBtn.anchor.set(0.5, 0.5);
50
51
//Enable input
52
//Call setListeners();
53
54
var bmpText;
55
bmpText = game.add.bitmapText(155, 400, 'pixelFont', '©2018 Ardan Labs', 21);
56
},
57
58
startGame: function (){
59
this.select_button = game.add.audio("select_button");
60
this.select_button.play('', 0, 1, false);
61
this.select_button.volume = 0.3;
62
this.titleSong.stop();
63
game.state.start("StateChoice");
64
},
65
66
startTutorial: function(){
67
this.titleSong.stop();
68
game.state.start("StateTutorial");
69
},
70
71
//Define setListeners function
72
//Add listeners for correct and incorrect screen orientation
73
74
update: function (){
75
this.mtn.tilePosition.x -= 1;
76
this.sky.tilePosition.x -= 0.5;
77
this.city.tilePosition.x -= 1.5;
78
},
79
80
}; //END StateTitle
81
82