made pause button switch states based on the actual gameState value rather than handlers

This commit is contained in:
lengstrom 2014-07-25 23:10:23 -04:00
parent 81c89548c4
commit f4b7b80c22
3 changed files with 4 additions and 12 deletions

View file

@ -123,6 +123,7 @@ function initialize(a) {
window.numHighScores = 3;
window.highscores = [];
debugger;
if(localStorage.getItem('highscores'))
highscores = JSON.parse(localStorage.getItem('highscores'));

View file

@ -59,6 +59,7 @@ function addKeyListeners() {
}
}
});
$("#pauseBtn").on('touchstart mousedown', function() {
if (gameState != 1 && gameState != -1) {
return;

View file

@ -161,17 +161,6 @@ function gameOverDisplay(){
showbottombar();
}
function togglePlayIcon (){
if ($($("#pauseBtn").children()[0]).attr('class').indexOf('pause') == -1) {
$("#pauseBtn").html('<i class="fa fa-pause fa-2x"></i>');
} else {
$("#pauseBtn").html('<i class="fa fa-play fa-2x"></i>');
}
return false;
}
function pause(o) {
localStorage.setItem('highscores', JSON.stringify(highscores));
var message;
@ -184,6 +173,7 @@ function pause(o) {
var c = document.getElementById("canvas");
if (gameState == -1) {
$("#pauseBtn").html('<i class="fa fa-play fa-2x"></i>');
if ($('#helpScreen').is(':visible')) {
$('#helpScreen').fadeOut(150, "linear");
}
@ -202,7 +192,7 @@ function pause(o) {
if (message == 'paused') {
showText(message);
}
$("#pauseBtn").html('<i class="fa fa-pause fa-2x"></i>');
prevGameState = gameState;
gameState = -1;
}