Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9234709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:51:12+00:00 2026-06-18T06:51:12+00:00

I am currently building a game using C#/XNA on VS2012 and on my code

  • 0

I am currently building a game using C#/XNA on VS2012 and on my code I want the user to touch an object and drag it vertically and horizontally without lifting the finger when switching to vertical or horizontal gesture. Here is a sample of my code:

protected override void Update(GameTime gameTime)
    {
        // Allows the game to exit
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            this.Exit();

        // Move the sprite by speed, scaled by elapsed time. 
        //shipPosition += shipSpeed; 

        // check whether gestures are available
        while (TouchPanel.IsGestureAvailable)
        {
            // read the next gesture
            GestureSample gesture = TouchPanel.ReadGesture();

            // has the user tapped the screen?
            switch (gesture.GestureType)
            {
                case GestureType.HorizontalDrag:

                    shipPosition += gesture.Delta;

                    break;
                case GestureType.VerticalDrag:

                    shipPosition += gesture.Delta;

                    break;
            }
        }

        // Make sure that the ship does not go out of bounds 
        shipPosition.X = MathHelper.Clamp(shipPosition.X, 35 / 2 , 765 + 35 / 2 - shipTexture.Width);
        shipPosition.Y = MathHelper.Clamp(shipPosition.Y, 21 / 2, 451 + 21 / 2 - shipTexture.Height);

        // TODO: Add your update logic here

        base.Update(gameTime);
    }

Can someone please advise? I saw somewhere that I have to use raw input touch but I would like to know how that works with drags.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:51:13+00:00Added an answer on June 18, 2026 at 6:51 am

    Sounds like you need to use Touch Location instead

    http://msdn.microsoft.com/en-us/library/ff434208.aspx

    look under

    Getting Multitouch Data from the Touch Input Device

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently building my project locally using MVC. The user enters some search
I'm currently building a website with Django and want to host user bio style
I am currently building a game in phonegap using jQuery Mobile frame work. What
I'm currently in the process of building a game using the MVC pattern. I
I'm building a little js quiz game. With the code below, the user selects
I am currently building a MUD (Multi-User-Domain) for an rpg game. Doing this entirely
I'm currently building a tool for my game engine using WPF. The tool is
With reference to this programming game I am currently building. I am using WPF
I am an Indie Game Developer, and I am currently building a game for
I'm currently building a reporting service (WCF) - filled reports are produced using an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.