added button to go to main menu from the pause menu
This commit is contained in:
parent
fe3875f2a9
commit
46d809cacf
4 changed files with 102 additions and 46 deletions
|
@ -1,6 +1,6 @@
|
|||
$(document).ready(initialize);
|
||||
|
||||
function initialize() {
|
||||
function initialize(a) {
|
||||
//view.js
|
||||
window.colors = ["#e74c3c", "#f1c40f", "#3498db", "#2ecc71"];
|
||||
window.hexColorsToTintedColors = {
|
||||
|
@ -116,58 +116,59 @@ function initialize() {
|
|||
window.gdy = 0;
|
||||
|
||||
window.devMode = 0;
|
||||
window.lastGen;
|
||||
window.prevTimeScored;
|
||||
window.nextGen;
|
||||
window.lastGen = undefined;
|
||||
window.prevTimeScored = undefined;
|
||||
window.nextGen = undefined;
|
||||
window.spawnLane = 0;
|
||||
window.importing = 0;
|
||||
window.importedHistory;
|
||||
window.startTime;
|
||||
window.importedHistory = undefined;
|
||||
window.startTime = undefined;
|
||||
|
||||
window.gameState;
|
||||
setStartScreen();
|
||||
|
||||
window.onblur = function (e) {
|
||||
if (gameState==1) {
|
||||
pause();
|
||||
}
|
||||
};
|
||||
|
||||
$('#startBtn').on('touchstart mousedown', function(){
|
||||
if (importing == 1) {
|
||||
init(1);
|
||||
} else {
|
||||
resumeGame();
|
||||
}
|
||||
|
||||
setTimeout(function(){
|
||||
if(settings.platform == "mobile"){
|
||||
document.body.addEventListener('touchstart', function(e) {
|
||||
handleClickTap(e.changedTouches[0].clientX);
|
||||
}, false);
|
||||
if (a != 1) {
|
||||
window.onblur = function (e) {
|
||||
if (gameState==1) {
|
||||
pause();
|
||||
}
|
||||
else {
|
||||
document.body.addEventListener('mousedown', function(e) {
|
||||
handleClickTap(e.clientX);
|
||||
}, false);
|
||||
};
|
||||
|
||||
$('#startBtn').on('touchstart mousedown', function(){
|
||||
if (importing == 1) {
|
||||
init(1);
|
||||
} else {
|
||||
resumeGame();
|
||||
}
|
||||
}, 1);
|
||||
});
|
||||
|
||||
setTimeout(function(){
|
||||
if(settings.platform == "mobile"){
|
||||
document.body.addEventListener('touchstart', function(e) {
|
||||
handleClickTap(e.changedTouches[0].clientX);
|
||||
}, false);
|
||||
}
|
||||
else {
|
||||
document.body.addEventListener('mousedown', function(e) {
|
||||
handleClickTap(e.clientX);
|
||||
}, false);
|
||||
}
|
||||
}, 1);
|
||||
});
|
||||
|
||||
document.addEventListener('touchmove', function(e) { e.preventDefault(); }, false);
|
||||
$(window).resize(scaleCanvas);
|
||||
$(window).unload(function(){
|
||||
if(gameState ==1 || gameState ==-1) localStorage.setItem("saveState", exportSaveState());
|
||||
else localStorage.clear();
|
||||
});
|
||||
document.addEventListener('touchmove', function(e) { e.preventDefault(); }, false);
|
||||
$(window).resize(scaleCanvas);
|
||||
$(window).unload(function(){
|
||||
if(gameState ==1 || gameState ==-1) localStorage.setItem("saveState", exportSaveState());
|
||||
else localStorage.clear();
|
||||
});
|
||||
|
||||
addKeyListeners();
|
||||
addKeyListeners();
|
||||
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-51272720-1', 'teamsnowman.github.io');
|
||||
ga('send', 'pageview');
|
||||
ga('create', 'UA-51272720-1', 'teamsnowman.github.io');
|
||||
ga('send', 'pageview');
|
||||
}
|
||||
}
|
|
@ -250,7 +250,13 @@ function animLoop() {
|
|||
render();
|
||||
break;
|
||||
|
||||
case 4:
|
||||
setTimeout(function(){initialize(1)}, 1);
|
||||
render();
|
||||
return;
|
||||
|
||||
default:
|
||||
initialize();
|
||||
setStartScreen();
|
||||
break;
|
||||
}
|
||||
|
|
43
js/view.js
43
js/view.js
|
@ -94,8 +94,8 @@ function toggleClass(element, active) {
|
|||
|
||||
function showText(text){
|
||||
var messages = {
|
||||
'paused':"<div class='centeredHeader unselectable'>Paused</div><br><div class='unselectable centeredSubHeader'>Press p to resume</div>",
|
||||
'pausedMobile':"<div class='centeredHeader unselectable'>Paused</div>",
|
||||
'paused':"<div class='centeredHeader unselectable'>Paused</div><br><div class='unselectable centeredSubHeader'>Press p to resume</div><div style='height:100px;line-height:100px;cursor:pointer;'><div class = 'centeredSubSubHeader'>Click here for the menu!</div></div>",
|
||||
'pausedMobile':"<div class='centeredHeader unselectable'>Paused</div><div style='height:100px;line-height:100px;cursor:pointer;'><div class = 'centeredSubSubHeader'>Tap here for the menu!</div></div>",
|
||||
'start':"<div class='centeredHeader unselectable' style='line-height:80px;'>Press enter to start</div>",
|
||||
'gameover':"<div class='centeredHeader unselectable'> Game Over: "+score+" pts</div><br><div style='font-size:24px;' class='centeredHeader unselectable'> High Scores:</div><table class='tg' style='margin:0px auto'>"
|
||||
};
|
||||
|
@ -140,6 +140,45 @@ function showText(text){
|
|||
}
|
||||
|
||||
pt.innerHTML = messages[text];
|
||||
|
||||
|
||||
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
|
||||
$("#restartBtn").on('touchstart', function() {
|
||||
if (gameState==2 || gameState==1 || importing == 1) {
|
||||
init(1);
|
||||
canRestart = false;
|
||||
}
|
||||
else if (gameState===0) {
|
||||
resumeGame();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
else {
|
||||
$("#restartBtn").on('mousedown', function() {
|
||||
if (gameState==2 || gameState==1 || importing == 1) {
|
||||
init(1);
|
||||
canRestart = false;
|
||||
}
|
||||
else if (gameState===0) {
|
||||
resumeGame();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (text == 'paused') {
|
||||
$(".centeredSubSubHeader").on('mousedown', function() {
|
||||
pause();
|
||||
setTimeout(function(){gameState = 4;}, 1);
|
||||
|
||||
});
|
||||
} else if (text == 'pausedMobile') {
|
||||
$(".centeredSubSubHeader").on('touchstart', function() {
|
||||
pause();
|
||||
setTimeout(function(){gameState = 4;}, 1);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function hideText(text){
|
||||
|
|
|
@ -168,6 +168,11 @@ and (max-device-width : 480px) {
|
|||
text-align:center;
|
||||
}
|
||||
|
||||
.centeredSubSubHeader {
|
||||
font-size:.7em;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
#overlay {
|
||||
margin-top: -20%;
|
||||
}
|
||||
|
@ -179,6 +184,11 @@ and (max-device-width : 480px) {
|
|||
text-align:center;
|
||||
}
|
||||
|
||||
.centeredSubSubHeader {
|
||||
font-size:1.4em;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.blur {
|
||||
opacity:0.1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue