var touchSound; var musicButton; var soundButton; var googlePlay; var gameOverState = { create: function() { // Black background game.add.image(0, 0, 'black'); // Button sound touchSound = game.add.audio('touchSound'); // Google play googlePlay = game.add.button(game.width / 2, 430, 'googlePlay', getIt) googlePlay.anchor.setTo(.5, 0); // Music button musicButton = game.add.button(0,0, 'musicButton', musicFunction, this); musicButton.input.useHandCursor = true; musicButton.x = 1215; musicButton.y = 430; if (game.global.musicOn) { musicButton.frame = 0; } else { musicButton.frame = 1; } // Sound button soundButton = game.add.button(0,0, 'soundButton', soundFunction, this); soundButton.input.useHandCursor = true; soundButton.x = 1135; soundButton.y = 430; if (game.global.soundOn) { soundButton.frame = 0; } else { soundButton.frame = 1; } // Buttons var moreGames = game.add.button(120, 220, 'moreGames', playMoreGames) moreGames.anchor.setTo(.5,.5) moreGames.input.useHandCursor = true; var home = game.add.button(110, 220, 'home', goToMenu) home.anchor.setTo(.5,.5) home.x = game.width / 2; home.input.useHandCursor = true; var tryAgain = game.add.button(280, 220, 'again', playAgain) tryAgain.anchor.setTo(.5,.5) tryAgain.input.useHandCursor = true; // Game over text var gameOverText = game.add.bitmapText(-400, 100, 'myfont', "Game over", 70); gameOverText.anchor.setTo(.5,.5) gameOverText.x = game.world.centerX - gameOverText.width / 2; // Tween game over text game.add.tween(gameOverText).to({x: game.world.centerX}, 1000).easing(Phaser.Easing.Bounce.Out).start(); // Update best score if (!localStorage.getItem('bestScore')) { localStorage.setItem('bestScore', 0); } if (game.global.score > localStorage.getItem('bestScore')) { localStorage.setItem('bestScore', game.global.score); DOTscore(game.global.score,"TwrOfMnstrsH5DOT",1,1); } // Display score and best score text var text = 'score: ' + game.global.score + ' best: ' + localStorage.getItem('bestScore'); var scoreLabel = game.add.bitmapText(400, 340, 'myfont', text, 44); scoreLabel.anchor.setTo(.5,.5) // Tween game over text game.add.tween(scoreLabel).to({x: game.world.centerX}, 1000).easing(Phaser.Easing.Bounce.Out).start(); }, }; function goToMenu() { if (game.global.soundOn) { touchSound.play(); } game.state.start('menu'); } function playAgain() { if (game.global.soundOn) { touchSound.play(); } game.state.start('level1'); } function playMoreGames() { if (game.global.soundOn) { touchSound.play(); } // this will open a link in a div that display this html5 game //window.location.href = "http://clarusgames.com"; // open in a new window (this might be blocked by popup blockers) window.open("http://clarusgames.com", "_blank"); } function getIt() { window.open("https://play.google.com/store/apps/details?id=com.clarusgames.tower.of.monsters", "_blank"); if (game.global.soundOn) { touchSound.play(); } } // Sound effects function muteSounds() { if (game.global.soundOn) { touchSound.play(); } //muteButton.frame = game.sound.mute ? 1 : 0; if (game.global.soundOn) { game.global.soundOn = false; soundButton.frame = 1; } else { game.global.soundOn = true; soundButton.frame = 0; } } // Music function muteMusic() { if (game.global.soundOn) { touchSound.play(); } if (game.global.musicOn) { music1.stop(); game.global.musicOn = false; musicButton.frame = 1; } else { music1.play(); game.global.musicOn = true; musicButton.frame = 0; } }