// This must be called manually each tick that the ScrollTracker is active. public void HandleInput(FarseerXNABase.ScreenSystem.InputHelper input) { // Turn on tracking as soon as we seen any kind of touch. We can't use gestures for this // because no gesture data is returned on the initial touch. We have to be careful to // pick out only 'Pressed' locations, because TouchState can return other events a frame // *after* we've seen GestureType.Flick or GestureType.DragComplete. if (!IsTracking) { for (int i = 0; i < input.TouchState.Count; i++) { if (input.TouchState[i].State == TouchLocationState.Pressed) { Velocity = Vector2.Zero; UnclampedViewOrigin = ViewOrigin; IsTracking = true; break; } } } foreach (GestureSample sample in input.Gestures) { switch (sample.GestureType) { case GestureType.VerticalDrag: UnclampedViewOrigin.Y -= sample.Delta.Y; break; case GestureType.Flick: // Only respond to mostly-vertical flicks if (Math.Abs(sample.Delta.X) < Math.Abs(sample.Delta.Y)) { IsTracking = false; Velocity = -sample.Delta; } break; case GestureType.DragComplete: IsTracking = false; break; case GestureType.Tap: break; } } }
/// <summary> /// Called once per frame to update the control; override this method if your control requires custom updates. /// Call base.Update() to update any child controls. /// </summary> public virtual void HandleInput(FarseerXNABase.ScreenSystem.InputHelper input) { for (int i = 0; i < ChildCount; i++) { children[i].HandleInput(input); } }
public override void HandleInput(FarseerXNABase.ScreenSystem.InputHelper input) { scrollTracker.HandleInput(input); base.HandleInput(input); }