2017-11-18 10:23:21 +01:00
|
|
|
var touch = data[Object.keys(data)[0]];
|
|
|
|
|
2017-11-19 17:27:57 +01:00
|
|
|
if (data.meta.zoom) {
|
|
|
|
console.log('zoom');
|
|
|
|
}
|
2017-11-19 14:50:09 +01:00
|
|
|
|
2017-11-18 13:49:24 +01:00
|
|
|
if (!this.initialized) {
|
|
|
|
|
|
|
|
this.x = window.innerWidth / 2;
|
|
|
|
this.y = window.innerHeight / 2;
|
2017-11-18 14:11:53 +01:00
|
|
|
|
2017-11-18 13:49:24 +01:00
|
|
|
this.initialized = true;
|
|
|
|
}
|
|
|
|
|
2017-11-18 14:17:44 +01:00
|
|
|
var sensitivity = 1;
|
2017-11-18 14:11:53 +01:00
|
|
|
|
2017-11-18 14:09:49 +01:00
|
|
|
this.x -= Math.round(touch.left * sensitivity);
|
|
|
|
this.x += Math.round(touch.right * sensitivity);
|
|
|
|
this.y -= Math.round(touch.up * sensitivity);
|
|
|
|
this.y += Math.round(touch.down * sensitivity);
|
2017-11-18 13:49:24 +01:00
|
|
|
|
|
|
|
if (this.x < 0) {
|
|
|
|
this.x = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.x > window.innerWidth) {
|
|
|
|
this.x = window.innerWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.y < 0) {
|
|
|
|
this.y = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.y > window.innerHeight) {
|
|
|
|
this.y = window.innerHeight;
|
|
|
|
}
|
|
|
|
|
2017-11-18 10:23:21 +01:00
|
|
|
GameLib.Event.Emit(
|
|
|
|
GameLib.Event.MOUSE_MOVE,
|
|
|
|
{
|
|
|
|
event : {
|
2017-11-18 13:49:24 +01:00
|
|
|
offsetX : this.x,
|
|
|
|
offsetY : this.y,
|
2017-11-18 10:23:21 +01:00
|
|
|
target : data.event.target
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
//@ sourceURL=touchMove.js
|