Skip to content

Instantly share code, notes, and snippets.

@pbrewczynski
Created July 10, 2013 22:51
Show Gist options
  • Save pbrewczynski/5970901 to your computer and use it in GitHub Desktop.
Save pbrewczynski/5970901 to your computer and use it in GitHub Desktop.
"use strict";
var myGame = {
config : {
canvasId : "game-canvas",
ballSize : "20%",
firstBallColor : "black",
secondBallColor : "yellow",
backgroundColor : "#b0da82"
},
canvas : null,
init : function () {
myGame.canvas = document.getElementById(myGame.config.canvasId);
myGame.canvas.setAttribute("height", window.innerHeight);
myGame.canvas.setAttribute("width", window.innerWidth);
myGame.canvas.style.backgroundColor = myGame.config.backgroundColor;
myGame.canvas.addEventListener("touchstart" ,myGame.onCanvasTouchStart ,false);
myGame.canvas.addEventListener("touchend" ,myGame.onCanvasTouchEnd ,false);
myGame.canvas.addEventListener("touchmove" ,myGame.onCanvasTouchMove ,false);
myGame.canvas.addEventListener("touchcancel" ,myGame.onCanvasTouchCancel ,false);
myGame.canvas.addEventListener("touchleave" ,myGame.onCanvasTouchLeave ,false);
myGame.canvas.data
},
onCanvasTouchStart : function (event) {
event.preventDefault();
console.log("Start");
console.log(event.changedTouches);
},
onCanvasTouchEnd : function (event) {
console.log("End");
},
onCanvasTouchCancel : function (event) {
console.log("Cancel");
},
onCanvasTouchLeave : function (event) {
console.log("Leave");
},
onCanvasTouchMove : function (event) {
console.log(event.changedTouches);
}
}
window.addEventListener("load", myGame.init,false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment