Path: blob/main/public/games/files/gopher-kart/js/stateTitle.js
1036 views
var StateTitle = {1preload: function(){2game.load.bitmapFont('pixelFont', 'assets/fonts/bitmapFonts/pixelFont.png', 'assets/fonts/bitmapFonts/pixelFont.xml');3game.load.audio("title", "assets/music/BeepBox-Song2-compressed.m4a");4game.load.image("city", "assets/city-re-colored.png");5game.load.audio("select_button", "assets/music/sfx/select.wav");6game.stage.backgroundColor = 0xe9fffe;7game.load.spritesheet("logo", "assets/menu-animation.png", 576, 334, 28);8//Need to add buttons for:9//1. Start game10//2. Tutorial??11game.load.spritesheet("buttons", "assets/main-menu-buttons.png", 217, 40, 2);12game.load.spritesheet("controls-buttons", "assets/controls-button.png", 108, 32, 2);13//Need: "best played in landscape-view image for mobile"1415//Temp button for tutorial button16game.load.image("tutorial", "assets/try-again.png");17game.load.image("background", "assets/bg-color.png");18game.load.image("sky", "assets/clouds-re-colored.png");19game.load.image("mtn", "assets/mountains-recolored.png");20},2122create: function (){23// game.scale.pageAlignHorizontally = true;24// game.scale.pageAlignVertically = true;25// game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;26// game.stage.disableVisibilityChange = true;2728background = game.add.tileSprite(0, 0, 600, 432, "background");29this.titleSong = game.add.audio("title");30this.titleSong.play('', 0, 1, true);3132this.sky = game.add.tileSprite(0, 10, 600, 78, "sky");33this.mtn = game.add.tileSprite(0, 295, 600, 131, "mtn");34this.city = game.add.tileSprite(0, 342, 600, 90, "city");3536this.logo = game.add.sprite(game.world.centerX, game.world.height-250, "logo");37this.logo.anchor.set(0.5, 0.5);38this.logo.animations.add("menu", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,3913, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28], 12, true);40this.logo.animations.play("menu");4142//Define and add game buttons43this.startBtn = game.add.button(285, game.world.height-60, "buttons", this.startGame, this, 1, 0, 1);44this.startBtn.anchor.set(0.5, 0.5);4546//Define and add game buttons47this.tutorial = game.add.button(486, game.world.height-37, "controls-buttons", this.startTutorial, this, 1, 0, 1);48this.startBtn.anchor.set(0.5, 0.5);4950//Enable input51//Call setListeners();5253var bmpText;54bmpText = game.add.bitmapText(155, 400, 'pixelFont', '©2018 Ardan Labs', 21);55},5657startGame: function (){58this.select_button = game.add.audio("select_button");59this.select_button.play('', 0, 1, false);60this.select_button.volume = 0.3;61this.titleSong.stop();62game.state.start("StateChoice");63},6465startTutorial: function(){66this.titleSong.stop();67game.state.start("StateTutorial");68},6970//Define setListeners function71//Add listeners for correct and incorrect screen orientation7273update: function (){74this.mtn.tilePosition.x -= 1;75this.sky.tilePosition.x -= 0.5;76this.city.tilePosition.x -= 1.5;77},7879}; //END StateTitle808182