diff --git a/data/life/life.js b/data/life/life.js index de9f5d2c..50f96f0c 100644 --- a/data/life/life.js +++ b/data/life/life.js @@ -2,7 +2,10 @@ // Card Conjurer, by Kyle Burton // //============================================// //define variables -var playerCount, startingLifeTotal, firstPlayerWide = false, lastPlayerWide = false, playerList = [], rowHeight = 0, columnWidth = 0, rowCount = 0, isFullscreen = true +var playerCount, startingLifeTotal, firstPlayerWide = false, lastPlayerWide = false, playerList = [], rowHeight = 0, columnWidth = 0, rowCount = 0, isFullscreen = true, isMobile = false +if ((typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1)) { + isMobile = true +} //This function sets everything up function fullscreen() { //Full screen! @@ -146,6 +149,9 @@ function playerBox(playerBoxID, canvasRotation, wide) { document.addEventListener("mouseup", function() { mouseUpPlayerBox(this) }) + window.addEventListener("touchstart", function() { + switchToTouchEvents() + }) } function configurePlayerBox(playerBoxID) { var currentPlayer = playerList[playerBoxID - 1] @@ -222,4 +228,16 @@ function enableNoSleep() { noSleep.enable(); document.removeEventListener('touchstart', enableNoSleep, false); } -document.addEventListener('touchstart', enableNoSleep, false); \ No newline at end of file +document.addEventListener('touchstart', enableNoSleep, false); + + +function switchToTouchEvents() { + document.removeEventListener("mousedown") + document.removeEventListener("mouseup") + document.addEventListener("touchstart", function() { + mouseDownPlayerBox(this, event.clientX, event.clientY) + }) + document.addEventListener("touchend", function() { + mouseUpPlayerBox(this) + }) +} \ No newline at end of file