From 5a74c5308e11694902751cf55556afd48201b420 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Sat, 24 Mar 2018 16:28:45 +0100 Subject: [PATCH] Update: CC - Snake FS - Touch End (0j2wxrtdf2.js) 658 bytes modified --- 0j2wxrtdf2.js | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/0j2wxrtdf2.js b/0j2wxrtdf2.js index be8deeb..449e4c5 100644 --- a/0j2wxrtdf2.js +++ b/0j2wxrtdf2.js @@ -10,6 +10,47 @@ if (!this.initialized) { } -console.log(data); +var touch = data; +var max = Math.max(touch.left, touch.right, touch.up, touch.down); + +if (typeof max === 'number') { + + if (max === touch.left) { + GameLib.Event.Emit( + GameLib.Event.KEY_DOWN, + { + keyCode : GameLib.System.Input.KEY_LEFT + } + ); + } + + if (max === touch.right) { + GameLib.Event.Emit( + GameLib.Event.KEY_DOWN, + { + keyCode : GameLib.System.Input.KEY_RIGHT + } + ); + } + + if (max === touch.up) { + GameLib.Event.Emit( + GameLib.Event.KEY_DOWN, + { + keyCode : GameLib.System.Input.KEY_UP + } + ); + } + + if (max === touch.down) { + GameLib.Event.Emit( + GameLib.Event.KEY_DOWN, + {{ + keyCode : GameLib.System.Input.KEY_DOWN + } + ); + } + +} //@ sourceURL=touchEnd.js \ No newline at end of file