From 40aafe04c8538b9985027a3afb3565618ae771c0 Mon Sep 17 00:00:00 2001 From: BKcore Date: Sat, 16 Mar 2013 16:13:06 +0100 Subject: [PATCH] Latest local changes for branching (3). --- bkcore.coffee/TouchController.coffee | 108 ----------------- bkcore.coffee/TouchController.js | 172 -------------------------- mobile.html | 175 --------------------------- 3 files changed, 455 deletions(-) delete mode 100644 bkcore.coffee/TouchController.coffee delete mode 100644 bkcore.coffee/TouchController.js delete mode 100644 mobile.html diff --git a/bkcore.coffee/TouchController.coffee b/bkcore.coffee/TouchController.coffee deleted file mode 100644 index 5768b5b..0000000 --- a/bkcore.coffee/TouchController.coffee +++ /dev/null @@ -1,108 +0,0 @@ -### - TouchController (stick + buttons) for touch devices - Based on the touch demo by Seb Lee-Delisle - - @class bkcore.TouchController - @author Thibaut 'BKcore' Despoulain -### -class TouchController - - @isTouchable: -> - return ('ontouchstart' of document.documentElement); - - ### - Creates a new TouchController - - @param dom DOMElement The element that will listen to touch events - @param stickMargin int The left margin in px for stick detection - @param buttonCallback function Callback for non-stick touches - ### - constructor: (@dom, @stickMargin=200, @buttonCallback=null) -> - @active = true - @touches = null - @stickID = -1 - @stickPos = new Vec2(0, 0) - @stickStartPos = new Vec2(0, 0) - @stickVector = new Vec2(0, 0) - - @dom.addEventListener('touchstart', ((e)=> @touchStart(e)), false) - @dom.addEventListener('touchmove', ((e)=> @touchMove(e)), false) - @dom.addEventListener('touchend', ((e)=> @touchEnd(e)), false) - - ### - @private - ### - touchStart: (event) -> - for i in [0..event.changedTouches.length] - touch = event.changedTouches[i] - if @stickID < 0 and touch.clientX < @stickMargin - @stickID = touch.identifier - @stickStartPos.set(touch.clientX, touch.clientY) - @stickPos.copy(@stickStartPos) - @stickVector.set(0, 0) - continue - else - @buttonCallback?(on, touch, event) - @touches = event.touches - false - - ### - @private - ### - touchMove: (event) -> - event.preventDefault() - for i in [0..event.changedTouches.length] - touch = event.changedTouches[i] - if @stickID is touch.identifier - @stickPos.set(touch.clientX, touch.clientY) - @stickVector.copy(@stickPos).substract(@stickStartPos) - break - @touches = event.touches - false - - ### - @private - ### - touchEnd: (event) -> - @touches = event.touches - for i in [0..event.changedTouches.length] - touch = event.changedTouches[i] - if @stickID is touch.identifier - @stickID = -1 - @stickVector.set(0, 0) - break - else - @buttonCallback?(off, touch, event) - false - -### - Internal class used for vector2 - @class Vec2 - @private -### -class Vec2 - - constructor: (@x = 0, @y = 0) -> - - substract: (vec) -> - @x -= vec.x - @y -= vec.y - @ - - copy: (vec) -> - @x = vec.x - @y = vec.y - @ - - set: (x, y) -> - @x = x - @y = y - @ - -### - Exports - @package bkcore -### -exports = exports ? @ -exports.bkcore ||= {} -exports.bkcore.TouchController = TouchController \ No newline at end of file diff --git a/bkcore.coffee/TouchController.js b/bkcore.coffee/TouchController.js deleted file mode 100644 index d14e922..0000000 --- a/bkcore.coffee/TouchController.js +++ /dev/null @@ -1,172 +0,0 @@ -// Generated by CoffeeScript 1.4.0 - -/* - TouchController (stick + buttons) for touch devices - Based on the touch demo by Seb Lee-Delisle - - @class bkcore.TouchController - @author Thibaut 'BKcore' Despoulain -*/ - - -(function() { - var TouchController, Vec2, exports; - - TouchController = (function() { - - TouchController.isTouchable = function() { - return 'ontouchstart' in document.documentElement; - }; - - /* - Creates a new TouchController - - @param dom DOMElement The element that will listen to touch events - @param stickMargin int The left margin in px for stick detection - @param buttonCallback function Callback for non-stick touches - */ - - - function TouchController(dom, stickMargin, buttonCallback) { - var _this = this; - this.dom = dom; - this.stickMargin = stickMargin != null ? stickMargin : 200; - this.buttonCallback = buttonCallback != null ? buttonCallback : null; - this.active = true; - this.touches = null; - this.stickID = -1; - this.stickPos = new Vec2(0, 0); - this.stickStartPos = new Vec2(0, 0); - this.stickVector = new Vec2(0, 0); - this.dom.addEventListener('touchstart', (function(e) { - return _this.touchStart(e); - }), false); - this.dom.addEventListener('touchmove', (function(e) { - return _this.touchMove(e); - }), false); - this.dom.addEventListener('touchend', (function(e) { - return _this.touchEnd(e); - }), false); - } - - /* - @private - */ - - - TouchController.prototype.touchStart = function(event) { - var i, touch, _i, _ref; - for (i = _i = 0, _ref = event.changedTouches.length; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) { - touch = event.changedTouches[i]; - if (this.stickID < 0 && touch.clientX < this.stickMargin) { - this.stickID = touch.identifier; - this.stickStartPos.set(touch.clientX, touch.clientY); - this.stickPos.copy(this.stickStartPos); - this.stickVector.set(0, 0); - continue; - } else { - if (typeof this.buttonCallback === "function") { - this.buttonCallback(true, touch, event); - } - } - } - this.touches = event.touches; - return false; - }; - - /* - @private - */ - - - TouchController.prototype.touchMove = function(event) { - var i, touch, _i, _ref; - event.preventDefault(); - for (i = _i = 0, _ref = event.changedTouches.length; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) { - touch = event.changedTouches[i]; - if (this.stickID === touch.identifier) { - this.stickPos.set(touch.clientX, touch.clientY); - this.stickVector.copy(this.stickPos).substract(this.stickStartPos); - break; - } - } - this.touches = event.touches; - return false; - }; - - /* - @private - */ - - - TouchController.prototype.touchEnd = function(event) { - var i, touch, _i, _ref; - this.touches = event.touches; - for (i = _i = 0, _ref = event.changedTouches.length; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) { - touch = event.changedTouches[i]; - if (this.stickID === touch.identifier) { - this.stickID = -1; - this.stickVector.set(0, 0); - break; - } else { - if (typeof this.buttonCallback === "function") { - this.buttonCallback(false, touch, event); - } - } - } - return false; - }; - - return TouchController; - - })(); - - /* - Internal class used for vector2 - @class Vec2 - @private - */ - - - Vec2 = (function() { - - function Vec2(x, y) { - this.x = x != null ? x : 0; - this.y = y != null ? y : 0; - } - - Vec2.prototype.substract = function(vec) { - this.x -= vec.x; - this.y -= vec.y; - return this; - }; - - Vec2.prototype.copy = function(vec) { - this.x = vec.x; - this.y = vec.y; - return this; - }; - - Vec2.prototype.set = function(x, y) { - this.x = x; - this.y = y; - return this; - }; - - return Vec2; - - })(); - - /* - Exports - @package bkcore - */ - - - exports = exports != null ? exports : this; - - exports.bkcore || (exports.bkcore = {}); - - exports.bkcore.TouchController = TouchController; - -}).call(this); diff --git a/mobile.html b/mobile.html deleted file mode 100644 index b532b17..0000000 --- a/mobile.html +++ /dev/null @@ -1,175 +0,0 @@ - - - - HexGL dev page - - - - - - - - -
- - - - - -
START LOW
START MID
START HIGH
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -