adjust sensitivity again

beta.r3js.org
-=yb4f310 2017-09-29 09:50:14 +02:00
parent 445df1a048
commit ccb92eb363
1 changed files with 20 additions and 37 deletions

View File

@ -253,62 +253,37 @@ GameLib.System.Input.prototype.onTouchMove = function (event) {
this.sensitivityCounter++; this.sensitivityCounter++;
var id = null; var id = null;
var t = null;
if (this.sensitivityCounter < this.touchSensitivity) { for (var t = 0; t < event.changedTouches.length; t++) {
/**
* ignore this event
*/
for (t = 0; t < event.changedTouches.length; t++) {
id = event.changedTouches[t].identifier;
this.touches[id].pageX = event.changedTouches[t].pageX;
this.touches[id].pageY = event.changedTouches[t].pageY;
}
} else {
this.sensitivityCounter = 0;
for (t = 0; t < event.changedTouches.length; t++) {
id = event.changedTouches[t].identifier; id = event.changedTouches[t].identifier;
var diffX = Math.abs(event.changedTouches[t].pageX - this.touches[id].pageX);
var diffY = Math.abs(event.changedTouches[t].pageY - this.touches[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 (event.changedTouches[t].pageX > this.touches[id].pageX) {
right += (event.changedTouches[t].pageX - this.touches[id].pageX); right += diffX;
// if (this.touches[id].left > 0) { left -= diffX;
// this.touches[id].left = 0;
// this.sensitivityCounter = this.touchSensitivity;
// }
} }
if (event.changedTouches[t].pageX < this.touches[id].pageX) { if (event.changedTouches[t].pageX < this.touches[id].pageX) {
left += (this.touches[id].pageX - event.changedTouches[t].pageX); left += diffX;
// if (this.touches[id].right > 0) { right -= diffX;
// this.touches[id].right = 0;
// this.sensitivityCounter = this.touchSensitivity;
// }
} }
if (event.changedTouches[t].pageY < this.touches[id].pageY) { if (event.changedTouches[t].pageY < this.touches[id].pageY) {
up += (this.touches[id].pageY - event.changedTouches[t].pageY); up += diffY;
// if (this.touches[id].down > 0) { down -= diffY;
// this.touches[id].down = 0;
// this.sensitivityCounter = this.touchSensitivity;
// }
} }
if (event.changedTouches[t].pageY > this.touches[id].pageY) { if (event.changedTouches[t].pageY > this.touches[id].pageY) {
down += (event.changedTouches[t].pageY - this.touches[id].pageY); down += diffY;
// if (this.touches[id].up > 0) { up -= diffY;
// this.touches[id].up = 0;
// this.sensitivityCounter = this.touchSensitivity;
// }
} }
this.touches[id].right += right; this.touches[id].right += right;
@ -317,15 +292,23 @@ GameLib.System.Input.prototype.onTouchMove = function (event) {
this.touches[id].down += down; this.touches[id].down += down;
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]);
} }
this.touches.event = event; this.touches.event = event;
if (this.sensitivityCounter >= this.touchSensitivity) {
this.sensitivityCounter = 0;
GameLib.Event.Emit( GameLib.Event.Emit(
GameLib.Event.TOUCH_MOVE, GameLib.Event.TOUCH_MOVE,
this.touches this.touches
); );
} }
}; };
GameLib.System.Input.prototype.onTouchCancel = function(event) { GameLib.System.Input.prototype.onTouchCancel = function(event) {