touch input updates
parent
e1adfbb990
commit
c810d60455
|
@ -588,6 +588,8 @@ GameLib.System.Input.prototype.onTouchStart = function(event) {
|
||||||
right : 0,
|
right : 0,
|
||||||
up : 0,
|
up : 0,
|
||||||
down : 0,
|
down : 0,
|
||||||
|
lastTouchX : event.touches[t].pageX,
|
||||||
|
lastTouchY : event.touches[t].pageY,
|
||||||
pageX : event.touches[t].pageX,
|
pageX : event.touches[t].pageX,
|
||||||
pageY : event.touches[t].pageY,
|
pageY : event.touches[t].pageY,
|
||||||
cancelled : false,
|
cancelled : false,
|
||||||
|
@ -613,40 +615,43 @@ GameLib.System.Input.prototype.onTouchMove = function (event) {
|
||||||
|
|
||||||
id = event.changedTouches[t].identifier;
|
id = event.changedTouches[t].identifier;
|
||||||
|
|
||||||
var diffX = Math.abs(event.changedTouches[t].pageX - this.touches[id].pageX);
|
if (this.touches[id]) {
|
||||||
var diffY = Math.abs(event.changedTouches[t].pageY - this.touches[id].pageY);
|
|
||||||
|
var diffX = Math.abs(this.touches[id].lastTouchX - event.changedTouches[id].pageX);
|
||||||
|
var diffY = Math.abs(this.touches[id].lastTouchY - event.changedTouches[id].pageY);
|
||||||
|
|
||||||
var left = 0;
|
var left = 0;
|
||||||
var right = 0;
|
var right = 0;
|
||||||
var up = 0;
|
var up = 0;
|
||||||
var down = 0;
|
var down = 0;
|
||||||
|
|
||||||
if (event.changedTouches[t].pageX > this.touches[id].pageX) {
|
if (this.touches[id].lastTouchX < event.changedTouches[id].pageX) {
|
||||||
right += diffX;
|
right += diffX;
|
||||||
left -= diffX;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.changedTouches[t].pageX < this.touches[id].pageX) {
|
if (this.touches[id].lastTouchX > event.changedTouches[id].pageX) {
|
||||||
left += diffX;
|
left += diffX;
|
||||||
right -= diffX;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.changedTouches[t].pageY < this.touches[id].pageY) {
|
if (this.touches[id].lastTouchY > event.changedTouches[id].pageY) {
|
||||||
up += diffY;
|
up += diffY;
|
||||||
down -= diffY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.changedTouches[t].pageY > this.touches[id].pageY) {
|
if (this.touches[id].lastTouchY < event.changedTouches[id].pageY) {
|
||||||
down += diffY;
|
down += diffY;
|
||||||
up -= diffY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.touches[id].right += right;
|
this.touches[id].right += right;
|
||||||
this.touches[id].left += left;
|
this.touches[id].left += left;
|
||||||
this.touches[id].up += up;
|
this.touches[id].up += up;
|
||||||
this.touches[id].down += down;
|
this.touches[id].down += down;
|
||||||
|
this.touches[id].lastTouchX = event.changedTouches[id].pageX;
|
||||||
|
this.touches[id].lastTouchY = event.changedTouches[id].pageY;
|
||||||
this.touches[id].pageX = event.changedTouches[t].pageX;
|
this.touches[id].pageX = event.changedTouches[t].pageX;
|
||||||
this.touches[id].pageY = event.changedTouches[t].pageY;
|
this.touches[id].pageY = event.changedTouches[t].pageY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//console.log(this.touches[id]);
|
//console.log(this.touches[id]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue