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. Note that since v0.8 you also have to init the TuioManager and have t oadd it as a listener to the TuioClient.
-
var tc:TuioClient = new TuioClient(new UDPConnector("127.0.0.1", 3000));
-
tc.addListener(TuioManager.init(stage));
-
var gm:GestureManager = GestureManager.init(stage);
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 ZoomGesture(TwoFingerMoveGesture.TRIGGER_MODE_MOVE));
The ZoomGesture 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.
Note that the ZoomGesture has two possible modes. TwoFingerMoveGesture.TRIGGER_MODE_MOVE and TwoFingerMoveGesture.TRIGGER_MODE_TOUCH. The first mode will only work with real Tuio input. The second mode on the other hand will also work if you use the NativeTuioAdapter or MouseTuioAdapter.
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;
October 10th, 2011 - 07:05
I’m having an issue with drag and zoom. It happens also with your DragRotateScaleMe example included in the 0.8 version.
I touch the object with one finger and it moves. Then I add another finger and I can zoom an rotate. But if I want to drag the object again, I have to remove both fingers and touch it again with one finger. If I just remove one of the finger the object won’t move.
Is that normal?
Can it be solved?
Cheers!
October 10th, 2011 - 21:21
Yes this is an expected behaviour because the drag gesture is started by a touch_down and cancelled if there are more than one finger on one object. So if you drag something and then start to scale or rotate it the draggesture will be killed and has to be restarted by retouching it.
You can have a look at the OneFingerMoveGesture class which defines the steps for the DragGesture and modify it to your liking.