Permalink
Browse files

added support for virtualjoystick.js

  • Loading branch information...
jeromeetienne committed Mar 2, 2013
1 parent 7dbfef2 commit 09cd4effa9d862908fa770ab12f7d224f6e881c9
@@ -0,0 +1,7 @@
+requirejs.config({
+ map : {
+ "*" : {
+ 'tquery.virtualjoystick' : 'plugins/virtualjoystick/vendor/virtualjoystick',
+ }
+ }
+});
@@ -11,7 +11,10 @@
var joystick = new VirtualJoystick({
container : document.body,
- mouseSupport : true
+ mouseSupport : true,
+ fireCallback : function(){
+ object.scaleBy(1.2)
+ }
});
world.loop().hook(function(delta, now){
@@ -6,6 +6,7 @@ var VirtualJoystick = function(opts)
this._baseEl = opts.baseElement || this._buildJoystickBase();
this._mouseSupport = 'mouseSupport' in opts? opts.mouseSupport : false;
this._range = opts.range || 60;
+ this._fireCallback = opts.fireCallback || function(){};
this._container.style.position = "relative";
@@ -123,10 +124,15 @@ VirtualJoystick.prototype._onUp = function()
this._baseX = this._baseY = 0;
this._stickX = this._stickY = 0;
+
+ if( (Date.now() - this._timestamp)/1000 < 0.5 ){
+ this._fireCallback()
+ }
}
VirtualJoystick.prototype._onDown = function(x, y)
{
+ this._timestamp = Date.now();
this._pressed = true;
this._baseX = x;
this._baseY = y;

0 comments on commit 09cd4ef

Please sign in to comment.