Skip to content
This repository
Browse code

added support for virtualjoystick.js

  • Loading branch information...
commit 09cd4effa9d862908fa770ab12f7d224f6e881c9 1 parent 7dbfef2
Jerome Etienne authored March 02, 2013
7  plugins/requirejs/confrequire/virtualjoystick.confrequire.js
... ...
@@ -0,0 +1,7 @@
  1
+requirejs.config({
  2
+	map	: {
  3
+		"*"	: {
  4
+			'tquery.virtualjoystick'	: 'plugins/virtualjoystick/vendor/virtualjoystick',
  5
+		}
  6
+	}
  7
+});
5  plugins/virtualjoystick/examples/index.html
@@ -11,7 +11,10 @@
11 11
 	
12 12
 	var joystick	= new VirtualJoystick({
13 13
 		container	: document.body,
14  
-		mouseSupport	: true
  14
+		mouseSupport	: true,
  15
+		fireCallback	: function(){
  16
+			object.scaleBy(1.2)
  17
+		}
15 18
 	});
16 19
 	
17 20
 	world.loop().hook(function(delta, now){
6  plugins/virtualjoystick/vendor/virtualjoystick.js
@@ -6,6 +6,7 @@ var VirtualJoystick	= function(opts)
6 6
 	this._baseEl		= opts.baseElement	|| this._buildJoystickBase();
7 7
 	this._mouseSupport	= 'mouseSupport' in opts? opts.mouseSupport	: false;
8 8
 	this._range		= opts.range		|| 60;
  9
+	this._fireCallback	= opts.fireCallback	|| function(){};
9 10
 
10 11
 	this._container.style.position	= "relative";
11 12
 
@@ -123,10 +124,15 @@ VirtualJoystick.prototype._onUp	= function()
123 124
 	
124 125
 	this._baseX	= this._baseY	= 0;
125 126
 	this._stickX	= this._stickY	= 0;
  127
+	
  128
+	if( (Date.now() - this._timestamp)/1000 < 0.5 ){
  129
+		this._fireCallback()
  130
+	}
126 131
 }
127 132
 
128 133
 VirtualJoystick.prototype._onDown	= function(x, y)
129 134
 {
  135
+	this._timestamp	= Date.now();
130 136
 	this._pressed	= true; 
131 137
 	this._baseX	= x;
132 138
 	this._baseY	= y;

0 notes on commit 09cd4ef

Please sign in to comment.
Something went wrong with that request. Please try again.