Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
onTouchUp: function(ev) {
touches = (typeof ev.changedTouches != 'undefined') ? ev.changedTouches : [ev];
for (var i = 0; i < touches.length; i++) {
ev.preventDefault();
touch = touches[i];
touchID = (typeof touch.identifier != 'undefined') ? touch.identifier : (typeof touch.pointerId != 'undefined') ? touch.pointerId : 1;
for(var i = 0; i < touchKeyArray.length; i++) {
extract = touchKeyArray[i].id;
if(extract == touchID) {
keyUp = touchKeyArray[i].function;
switch(keyUp) {
case Game.KEY.Q: if (!this.game.leftPaddle.auto) this.game.leftPaddle.stopMovingUp(); break;
case Game.KEY.A: if (!this.game.leftPaddle.auto) this.game.leftPaddle.stopMovingDown(); break;
case Game.KEY.P: if (!this.game.rightPaddle.auto) this.game.rightPaddle.stopMovingUp(); break;
case Game.KEY.L: if (!this.game.rightPaddle.auto) this.game.rightPaddle.stopMovingDown(); break;
}
console.log(touchKeyArray[i].function)
if(touchKeyArray.length == 1) {
touchKeyArray = [];
} else {
delete touchKeyArray[i];
}
}
}
}
},
onTouchDown: function(ev) {
touches = (typeof ev.changedTouches != 'undefined') ? ev.changedTouches : [ev];
for (var i = 0; i < touches.length; i++) {
ev.preventDefault();
touch = touches[i];
touchID = (typeof touch.identifier != 'undefined') ? touch.identifier : (typeof touch.pointerId != 'undefined') ? touch.pointerId : 1;
var wc = document.getElementById("RahmenFuerPong").offsetWidth;
var hc = document.getElementById("RahmenFuerPong").offsetHeight;
var touchOffsetY = touch.pageY - document.getElementById("RahmenFuerPong").offsetTop;
var touchOffsetX = touch.pageX - document.getElementById("RahmenFuerPong").offsetLeft;
if (!helpthisplaying.playing) {
// If-Bedingung die "nichts" mit dem Rest zu tun hat, deswegen ausgeschnitten
} else {
if (this.game.onkeydown) {
if (touchOffsetX > wc / 2) {
if (touchOffsetY > hc / 2) {
if (!this.game.rightPaddle.auto) this.game.rightPaddle.moveDown();
touchExpand = 76;
} else {
if (!this.game.rightPaddle.auto) this.game.rightPaddle.moveUp();
touchExpand = 80;
}
} else {
if (touchOffsetY > hc / 2) {
if (!this.game.leftPaddle.auto) this.game.leftPaddle.moveDown();
touchExpand = 65;
} else {
if (!this.game.leftPaddle.auto) this.game.leftPaddle.moveUp();
touchExpand = 81;
}
}
for(var i = 0; i < touchKeyArray.length; i++) {
extract = touchKeyArray[i].id;
if(extract == touchID) {
doubled = true;
}
}
if(doubled == false) {
touchFinishedExpand = { "function": touchExpand, "id": touchID };
touchKeyArray.push(touchFinishedExpand);
}
}
}
}
},