removed callback stacking issues

This commit is contained in:
lengstrom 2014-07-19 18:03:16 -04:00
parent 0eba942db5
commit 4b9e179db9
2 changed files with 25 additions and 8 deletions

View file

@ -126,13 +126,14 @@ function initialize(a) {
window.gameState;
setStartScreen();
if (a != 1) {
window.onblur = function (e) {
if (gameState==1) {
pause();
}
};
$('#startBtn').off();
$('#startBtn').on('touchstart mousedown', function(){
if (importing == 1) {
init(1);
@ -142,14 +143,22 @@ function initialize(a) {
setTimeout(function(){
if(settings.platform == "mobile"){
document.body.addEventListener('touchstart', function(e) {
handleClickTap(e.changedTouches[0].clientX);
}, false);
try {
document.body.removeEventListener('touchstart', handleTap ,false);
} catch (e) {
}
document.body.addEventListener('touchstart', handleTap, false);
}
else {
document.body.addEventListener('mousedown', function(e) {
handleClickTap(e.clientX);
}, false);
try {
document.body.removeEventListener('mousedown', handleClick ,false);
} catch (e) {
}
document.body.addEventListener('mousedown', handleClick, false);
}
}, 1);
});
@ -171,4 +180,12 @@ function initialize(a) {
ga('create', 'UA-51272720-1', 'teamsnowman.github.io');
ga('send', 'pageview');
}
}
function handleTap(e) {
handleClickTap(e.changedTouches[0].clientX);
}
function handleClick(e) {
handleClickTap(e.clientX);
}

View file

@ -104,7 +104,7 @@ function showText(text){
var allZ = 1;
var i;
for (i = 0; i < 3; i++) {
if (highscores[i] != undefined && highscores[i] != 0) {
if (highscores[i] !== undefined && highscores[i] != 0) {
messages['gameover'] += "<tr> <th class='tg-031e'>1.</th> <th class='tg-031e'>"+highscores[i] + " pts</th> </tr>";
}
}