From 43af2bebd1de70f0e2f5627815812dbfd01a5c9a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 5 Aug 2014 15:30:07 -0400 Subject: cutting out stuff for mobile --- .../mx/extensions/mx.movementsMobile.js | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 public/assets/javascripts/mx/extensions/mx.movementsMobile.js (limited to 'public/assets/javascripts/mx/extensions/mx.movementsMobile.js') diff --git a/public/assets/javascripts/mx/extensions/mx.movementsMobile.js b/public/assets/javascripts/mx/extensions/mx.movementsMobile.js new file mode 100644 index 0000000..7e1cc92 --- /dev/null +++ b/public/assets/javascripts/mx/extensions/mx.movementsMobile.js @@ -0,0 +1,56 @@ + +MX.MobileMovements = function (cam) { + + var touching = true, + moving = false, + v = 12, + vr = Math.PI * 0.012, + jumpV = 23, + vx = vy = vz = 0, + creepFactor = 0.3 + + var DEFAULT_SCALE = 1.0, scale = DEFAULT_SCALE + + var pos = { x: 0, y: 0, z: 0, rotationX: 0, rotationY: 0 } + + var mouse = new Rect( 0,0,0,0 ) + + return { + + init: function () { + document.addEventListener("touchstart", function(e){ + if (e.touches.length == 1) { + touching = true + mouse.x.a = mouse.x.b = event.touches[ 0 ].pageX + mouse.y.a = mouse.y.b = event.touches[ 0 ].pageY + } + }) + document.addEventListener("touchmove", function(e){ + if (e.touches.length == 1) { + + } + }) + document.addEventListener("touchend", function(e){ + if (e.touches.length == 0) { + touching = false + mouse.zero() + } + }) + }, + + update: function () { + if (moving) { + app.tube("move", pos) + } + }, + + lock: function(){ locked = true }, + unlock: function(){ locked = false }, + scale: function(n){ if (n) scale = n; return scale }, + resetScale: function(n){ scale = DEFAULT_SCALE }, + gravity: function(g){ return typeof g == "boolean" ? gravity = g : gravity }, + velocity: function(n){ v = clamp(n, 1, 50) }, + jumpVelocity: function(n){ jumpV = clamp(n, 1, 50) }, + } + +} -- cgit v1.2.3-70-g09d2