Update life.js

This commit is contained in:
Kyle
2019-08-10 16:22:30 -07:00
parent b3c658ea0b
commit 3a3b44baf7

View File

@@ -6,6 +6,7 @@ var playerCount, startingLifeTotal, firstPlayerWide = false, lastPlayerWide = fa
if ((typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1)) { if ((typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1)) {
isMobile = true isMobile = true
} }
window.addEventListener("touchstart", switchToTouchEvents)
//This function sets everything up //This function sets everything up
function fullscreen() { function fullscreen() {
//Full screen! //Full screen!
@@ -145,7 +146,6 @@ function playerBox(playerBoxID, canvasRotation, wide) {
document.getElementById("mainGrid").appendChild(this.canvas) document.getElementById("mainGrid").appendChild(this.canvas)
this.canvas.addEventListener("mousedown", decoyMouseDownFunction) this.canvas.addEventListener("mousedown", decoyMouseDownFunction)
document.addEventListener("mouseup", decoyMouseUpFunction) document.addEventListener("mouseup", decoyMouseUpFunction)
window.addEventListener("touchstart", switchToTouchEvents)
} }
function decoyMouseDownFunction() { function decoyMouseDownFunction() {
alert("IT'S STILL CLICKING") alert("IT'S STILL CLICKING")
@@ -224,12 +224,14 @@ function updateBackgroundColor(color) {
function switchToTouchEvents() { function switchToTouchEvents() {
document.removeEventListener("mousedown", decoyMouseDownFunction) window.removeEventListener("touchstart", switchToTouchEvents)
document.removeEventListener("mouseup", decoyMouseUpFunction) for (var i = 1; i <= playerCount; i++) {
document.addEventListener("touchstart", function() { playerList[i - 1].canvas.removeEventListener("mousedown", decoyMouseDownFunction)
playerList[i - 1].canvas.addEventListener("touchstart", function() {
mouseDownPlayerBox(this, event.clientX, event.clientY) mouseDownPlayerBox(this, event.clientX, event.clientY)
}) })
document.addEventListener("touchend", function() { playerList[i - 1].canvas.addEventListener("touchend", function() {
mouseUpPlayerBox(this) mouseUpPlayerBox(this)
}) })
}
} }