summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/mx/extensions/mx.movementsMobile.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/mx/extensions/mx.movementsMobile.js')
-rw-r--r--public/assets/javascripts/mx/extensions/mx.movementsMobile.js56
1 files changed, 56 insertions, 0 deletions
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) },
+ }
+
+}