From 24b92122472a621b7d7496a5ae6f8c038ad57d72 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Thu, 28 Sep 2017 12:03:59 +0200 Subject: [PATCH] send events too --- src/game-lib-system-input.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/game-lib-system-input.js b/src/game-lib-system-input.js index 30a29ac..4299781 100644 --- a/src/game-lib-system-input.js +++ b/src/game-lib-system-input.js @@ -63,17 +63,8 @@ GameLib.System.Input.prototype.start = function() { this.mouseControls = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Controls.Mouse); /** - * If we have editor controls - start behaving like it... + * If we have touch controls - inject them first so we can override editor controls if necessary */ - - - - if (this.editorControls.length > 0) { - - - - } - if (this.touchControls.length > 0) { this.touchControls.map( @@ -101,9 +92,8 @@ GameLib.System.Input.prototype.start = function() { ); }.bind(this) ) - } else if ( - this.editorControls.length > 0 - ) { + } else if (this.editorControls.length > 0) { + this.renderers = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Renderer); this.renderers.map( @@ -193,7 +183,8 @@ GameLib.System.Input.prototype.onTouchStart = function(event) { pageX : event.touches[t].pageX, pageY : event.touches[t].pageY, cancelled : false, - ended : false + ended : false, + event : event }; } @@ -236,6 +227,7 @@ GameLib.System.Input.prototype.onTouchMove = function(event) { this.touches[id].down += down; this.touches[id].pageX = event.changedTouches[t].pageX; this.touches[id].pageY = event.changedTouches[t].pageY; + this.touches.event = event; } GameLib.Event.Emit( @@ -247,6 +239,7 @@ GameLib.System.Input.prototype.onTouchMove = function(event) { GameLib.System.Input.prototype.onTouchCancel = function(event) { for (var t = 0; t < event.changedTouches.length; t++) { this.touches[event.changedTouches[t].identifier].cancelled = true; + this.touches[event.changedTouches[t].identifier].event = event; GameLib.Event.Emit( GameLib.Event.TOUCH_CANCEL, this.touches[event.changedTouches[t].identifier] @@ -258,6 +251,7 @@ GameLib.System.Input.prototype.onTouchCancel = function(event) { GameLib.System.Input.prototype.onTouchEnd = function(event) { for (var t = 0; t < event.changedTouches.length; t++) { this.touches[event.changedTouches[t].identifier].ended = true; + this.touches[event.changedTouches[t].identifier].event = event; GameLib.Event.Emit( GameLib.Event.TOUCH_END, this.touches[event.changedTouches[t].identifier]