added info button support in home screen; made hit detection basde on canvas coordinates rather than DOM for info button
This commit is contained in:
parent
3a533d93b7
commit
7d36457851
6 changed files with 42 additions and 34 deletions
|
@ -33,8 +33,9 @@
|
|||
<script type = 'text/javascript' src="js/input.js"></script>
|
||||
<script type = 'text/javascript' src="js/main.js"></script>
|
||||
<script type = 'text/javascript' src="js/initialization.js"></script>
|
||||
<div id="attributions" >Initially built by <a href="http://github.com/teamsnowman">@teamsnowman</a> at a Hackathon<br>
|
||||
Continued by <a href="http://github.com/garrettdreyfus">@garrettdreyfus</a> and <a href="http://github.com/meadowstream" >@meadowstream</a> on <a href = 'http://github.com/hextris/hextris'>GitHub</a></div>
|
||||
<div id="attributions">Initially built by <a href="http://github.com/teamsnowman">@teamsnowman</a> at a 13 hr Hackathon<br>
|
||||
Continued by <a href="http://github.com/garrettdreyfus">Garrett Finucane</a> & <a href="http://github.com/meadowstream" >Logan Engstrom</a> on <a href = 'http://github.com/hextris/hextris'>GitHub</a>
|
||||
</div>
|
||||
<div id='startBtn' style='position:absolute;left:40%;top:38%;height:25%;width:25%;z-index:99999999;cursor:pointer;'></div>
|
||||
<div id="helpScreen" class = 'unselectable'>
|
||||
<h1 class = 'instructions_body'>Instructions</h1>
|
||||
|
|
|
@ -159,10 +159,10 @@ function initialize(a) {
|
|||
|
||||
if (settings.platform == 'mobile') {
|
||||
$('#startBtn').on('touchstart',startBtnHandler);
|
||||
$('.helpText').on('touchstart',showHelp);
|
||||
// $('.helpText').on('touchstart',function(){if (gameState != 2) showHelp});
|
||||
} else {
|
||||
$('#startBtn').on('mousedown',startBtnHandler);
|
||||
$('.helpText').on('mousedown',showHelp);
|
||||
// $('.helpText').on('mousedown',function(){if (gameState != 2) showHelp});
|
||||
}
|
||||
|
||||
document.addEventListener('touchmove', function(e) { e.preventDefault(); }, false);
|
||||
|
@ -181,21 +181,6 @@ function initialize(a) {
|
|||
document.addEventListener("pause", handlePause, false);
|
||||
document.addEventListener("backbutton", handlePause, false);
|
||||
document.addEventListener("menubutton", handlePause, false); //menu button on android
|
||||
}
|
||||
}
|
||||
|
||||
function startBtnHandler() {
|
||||
if (!canRestart) return false;
|
||||
|
||||
if ($('#helpScreen').is(':visible')) {
|
||||
$('#helpScreen').fadeOut(150, "linear");
|
||||
}
|
||||
|
||||
if (importing == 1) {
|
||||
init(1);
|
||||
} else {
|
||||
resumeGame();
|
||||
}
|
||||
|
||||
setTimeout(function(){
|
||||
if(settings.platform == "mobile"){
|
||||
|
@ -218,6 +203,21 @@ function startBtnHandler() {
|
|||
}
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function startBtnHandler() {
|
||||
if (!canRestart) return false;
|
||||
|
||||
if ($('#helpScreen').is(':visible')) {
|
||||
$('#helpScreen').fadeOut(150, "linear");
|
||||
}
|
||||
|
||||
if (importing == 1) {
|
||||
init(1);
|
||||
} else {
|
||||
resumeGame();
|
||||
}
|
||||
}
|
||||
|
||||
function handlePause() {
|
||||
if (gameState == 1 || gameState == 2) {
|
||||
|
@ -226,9 +226,9 @@ function handlePause() {
|
|||
}
|
||||
|
||||
function handleTap(e) {
|
||||
handleClickTap(e.changedTouches[0].clientX);
|
||||
handleClickTap(e.changedTouches[0].clientX, e.changedTouches[0].clientY);
|
||||
}
|
||||
|
||||
function handleClick(e) {
|
||||
handleClickTap(e.clientX);
|
||||
handleClickTap(e.clientX, e.clientY);
|
||||
}
|
||||
|
|
|
@ -86,7 +86,13 @@ function addKeyListeners() {
|
|||
});
|
||||
}
|
||||
}
|
||||
function handleClickTap(x) {
|
||||
|
||||
function handleClickTap(x,y) {
|
||||
if (x < 120 && y < 50 && $('.helpText').is(':visible')) {
|
||||
showHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameState == 2 && canRestart) {
|
||||
init(1);
|
||||
return;
|
||||
|
|
|
@ -223,6 +223,7 @@ function animLoop() {
|
|||
|
||||
if ($('#pauseBtn').is(':visible')) $('#pauseBtn').fadeOut(150, "linear");
|
||||
if ($('#restartBtn').is(':visible')) $('#restartBtn').fadeOut(150, "linear");
|
||||
if (!$('.helpText').is(':visible')) $('.helpText').fadeIn(150, "linear");
|
||||
|
||||
showbottombar();
|
||||
canRestart = 0;
|
||||
|
@ -309,7 +310,7 @@ function checkGameOver() {
|
|||
}
|
||||
|
||||
function showHelp(){
|
||||
if (gameState == 1 || gameState == 2) {
|
||||
if (gameState == 1) {
|
||||
pause();
|
||||
}
|
||||
|
||||
|
|
|
@ -195,14 +195,14 @@ function pause(o) {
|
|||
$('#helpScreen').fadeOut(150, "linear");
|
||||
}
|
||||
|
||||
$('.helpText').hide();
|
||||
$('.helpText').fadeOut(200, 'linear');
|
||||
hideText();
|
||||
hidebottombar();
|
||||
gameState = prevGameState;
|
||||
|
||||
}
|
||||
else if(gameState != -2 && gameState !== 0 && gameState !== 2) {
|
||||
$('.helpText').show();
|
||||
$('.helpText').fadeIn(200, 'linear');
|
||||
showbottombar();
|
||||
if (message == 'paused') {
|
||||
console.log("sup");
|
||||
|
|
|
@ -174,7 +174,7 @@ and (max-device-width : 480px) {
|
|||
position:absolute;
|
||||
width:100%;
|
||||
left: 0%;
|
||||
top: 70%;
|
||||
top: 72%;
|
||||
text-align:center;
|
||||
font-size:1.25em;
|
||||
z-index:98;
|
||||
|
@ -190,7 +190,7 @@ and (max-device-width : 580px) {
|
|||
}
|
||||
|
||||
#attributions {
|
||||
font-size:.6em;
|
||||
font-size:.7em;
|
||||
}
|
||||
|
||||
.centeredSubHeader {
|
||||
|
|
Loading…
Reference in a new issue