Using the GestureManager
In this article I'll explain how to use the GestureManager. It's basically used just like the TuioManager which means that the GestureManager is also a singleton and is started by calling the init(...) function.
-
var tc:TuioClient = new TuioClient(new TCPConnector("127.0.0.1", 3000));
-
var gm:GestureManager = GestureManager.init(stage, tc);
Apart from that you'll also have to tell the GestureManager which gestures to use. You can do this by calling the addGesture(...) method.
-
GestureManager.addGesture(new ScaleGesture());
The ScaleGesture is one of the included ones but you can add your own gestures in exactly the same way. How to create gestures is explained in the "Creating custom Gestures" article.
You can also configure the touchTargetDiscoveryMode and the ignoreList like with the TuioManager but in order to use these correctly it is important to know that the GestureManager actually uses the TuioManager in order to work. That's why you should configure these properties on both the TuioManager and the GestureManager to make sure everything works as expected.
Here is a little snippet that shows how changing the touchTargetDiscoveryMode would look like.
-
gm.touchTargetDiscoveryMode = GestureManager.TOUCH_TARGET_DISCOVERY_NONE;
-
TuioManager.getInstance().touchTargetDiscoveryMode = TuioManager.TOUCH_TARGET_DISCOVERY_NONE;
August 25th, 2010 - 11:40
I still don’t understand how I can assign a Gesture-Event to a MovieClip.
e.g.:
this.addEventListener(TransformGestureEvent.GESTURE_ZOOM, handleScale);
How is that done while I use Windows7TouchToTuioDispatcher?
August 25th, 2010 - 17:42
You simply have to call GestureManager.init() instead of TuioManager.init() then in theory it should work. “In theory” because Windows7TouchToTuioDispatcher hasn’t actually been tested yet together with the GestureManager.
So this would look somewhat like this:
Adding listeners works then like you described it. Also have a look at the GestureManagerExample files for the listener part.
August 25th, 2010 - 19:01
I tried the DragRotateScale-Example.
As soon as I put in this line I don’t get TransformGestureEvents anymore:
var winTouch:Windows7TouchToTuioDispatcher = new Windows7TouchToTuioDispatcher(fenster.stage, false, false);
Thats ok, because the Windows7TouchToTuioDispatcher gets them and dispatches Tuio Touchevents.
I’d however like to get some kind of GestureEvents from TUIO.
Is that possible?
August 26th, 2010 - 00:39
Have a look at the comments in this post:
http://bubblebird.at/tuioflash/guides/native-to-touch-mouse-to-touch/
There currently is a bug that results in no TOUCH_MOVE events beeing dispatched which are essential for the included gestures.
I’ll try to fix this in the next few days in the svn version. What you can do is add constant values to the createTuioContainer part in the Windows7TouchToTuio Dispatcher like this:
[code lang="actionscript3"]
private function createTuioContainer(event:TouchEvent):TuioContainer{
return new TuioContainer("2Dcur",event.touchPointID,event.stageX/stage.stageWidth, event.stageY/stage.stageHeight,0,0.1,0.1,0.1,0,0);
}
[/lang]