Detecting rotate gestures
A common gesture for manipulating objects on the screen is to use the twist or rotate gesture. This is often more natural than entering a rotation value or dragging a cursor.
How to do it...
Another multifinger gesture that is very common is the rotate gesture. For a two-finger rotate, we can do something very similar to what we would do when implementing the ScaleGestureDetector
instance. However, we do have to create a RotateGestureDetector
instance ourselves as this is not currently provided by the framework. We will create RotateGestureDetector
by preforming the following steps:
- First, we need an interface that represents our gesture detector's events:
public interface IOnRotateGestureListener { bool OnRotateBegin(RotateGestureDetector detector); void OnRotate(RotateGestureDetector detector); void OnRotateEnd(RotateGestureDetector detector); }
- Then, we create the gesture detector type:
public class RotateGestureDetector { private float oldX2, oldY2,...