locked
Detecting holds in a freedrag gesture RRS feed

  • Question

  • Hi, I'm coding a game with Monogame and Fraseer. I need to move objects accurately around with touch. When I drag on an object to a specific location I need to exert a force on that object. However when I get to the specific location with still a finger pressed no more gesture is recorded and so the whole motion looks like a flick. (ie. the object just moves on the same direction as the sum of all the previous force vectors).

    Does any one have any idea how I can keep reading a freedrag even if the finger isn't moved anymore?

    I provide the short snippet of the code in charge of reading the gestures below:

     if (isDeviceTouchEnable)
                    {
                        if (touches.Count > 0)
                        {
                            if (touches[0].State == TouchLocationState.Pressed)
                            {
     
                                touchPressed = true;
                            }
                            while (TouchPanel.IsGestureAvailable)
                            {
                                gestureState = TouchPanel.ReadGesture();
                                if (gestureState.GestureType == GestureType.Tap)
                                {
                                    touchTap = true;
                                    touchTapCoord = gestureState.Position;
    
                                }
                                else if (gestureState.GestureType == GestureType.FreeDrag)
                                {
                                    touchDrag = true;
                                    touchTapCoord = gestureState.Position;
                        
                                    deltaXYTouch = deltaXYTouch ?? Vector2.Zero;
                                    deltaXYTouch += gestureState.Delta;
                                }
                            }
                        }
                    }

    Wednesday, August 14, 2013 9:26 PM

Answers

All replies

  • Hi Esmail,

    You may want to post this on the Monogame discussion board. The Building Windows Store apps with C# or VB forum targets Microsoft technologies and you are less likely to find experts on 3rd party toolkits such as Monogame here.

    That said, there may be community members with Monogame experience who can help you out here.

    --Rob

    • Marked as answer by Anne Jing Thursday, August 22, 2013 3:05 AM
    Wednesday, August 14, 2013 9:40 PM
    Moderator
  • Thanks for the reply, I just mentioned the game and its framework for the sake of the context.

    My problem is that once a freedrag gesture becomes stationary it no longer registers as a gesture.

    So it has nothing to do with Monogame or any other 3rd party framework.

    Wednesday, August 14, 2013 11:12 PM
  • The gesture system in your code snippet is not part of Windows 8. I assume it is part of Monogame. 

    None of TouchPanel, ReadGesture, GestureType, FreeDrag, etc. come from either Windows.UI.Input or Windows.UI.Xaml. They probably wrap Windows' native GestureRecognizer class, but the mapping isn't obviously one-to-one.

    If you use the GestureRecognizer with GestureSettings to listen for ManipulationTranslateX and ManipulationTranslateY you will continue to get ManipulationUpdated events for the drag so long as the touch is down, even if the user pauses and holds in the middle.

    --Rob

    Wednesday, August 14, 2013 11:43 PM
    Moderator
  • yes, I do apologize Rob, they belong to Microsoft.XNA.Framework.Input.Touch. I thought this forum covers XNA as well. I might have to look into other options that you mentioned.
    Thursday, August 15, 2013 12:43 AM
  • Hi Esmail,

    XNA is not provided by Microsoft for Windows Store apps. Monogame is a 3rd party toolkit which provides XNA compatible functionality.

    --Rob

    Thursday, August 15, 2013 12:51 AM
    Moderator