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 8159439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:54:52+00:00 2026-06-06T17:54:52+00:00

Trying to make an xna game, where the user needs to tap to stop

  • 0

Trying to make an xna game, where the user needs to tap to stop a bar going down. The simulation is like what we see in a WWE PS3/xbox game, the give up bar.

Anyway, the way i have done it, serves the purpose. However, if the user holds the touch, touch values keep incrementing.

What I want is, if the user taps it, only 1 point will be scored. And when he taps again, he will get 1 point more. At the moment what is happening is, if the user holds it, it keeps incrementing, kind of like in a keyboard (if u hold a button, keypresses keeps going on).

            foreach (TouchLocation location in TouchPanel.GetState())
            {

                if (location.State == TouchLocationState.Moved)
                {
                    touchPoints++;
                    break;
                }
            }
  • 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-06T17:54:55+00:00Added an answer on June 6, 2026 at 5:54 pm

    Change from TouchLocationState.Moved to TouchLocationState.Pressed. That should only occur with each new touch.

            foreach (TouchLocation location in TouchPanel.GetState())
            {
                TouchLocation prevLocation; 
                bool prevLocationAvailable = location.TryGetPreviousLocation(out prevLocation);
    
                if (location.State == TouchLocationState.Pressed && prevLocation.State != TouchLocationState.Pressed)
                {
                    touchPoints++;
                    break;
                }
            }
    

    And for the future, if you’re doing Keyboard input and want each press of the keyboard to increment the value but to be ignored if the player is holding down the space, you just have to store the previous state of the keyboard. Then you compare if the current keyboard state the key is being pressed and the previous keyboard state the key wasn’t pressed.

    (didn’t actually code in compiler so there could be some code issues with the below)

    KeyboardState currentKeyboardState = Keyboard.GetState();
    if (currentKeyboardState.IsKeyDown(Keys.Space) && !previousKeyboardState.IsKeyDown(Keys.Space) {
        //Do whatever it is you want to do with the press of the space key
    }
    previousKeyboardState = currentKeyboardState;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a Tetris-like game in XNA, and currently I'm thinking of
I have just started trying to make a simple game with XNA 3.1 to
I'm a starter in XNA and I'm trying to make a pong-game. I've been
I am trying to make a simple 3D game for windows with XNA and
I'm trying to make a zoom system for a C#/XNA game I'm working on.
Using XNA, I'm trying to make an adventure game engine that lets you make
I'm trying to make a small XNA-based game, and I need to be able
I am trying to make my first app using XNA, and I am having
I'm trying make a login window where a user is prompted to enter their
Trying to make a simple number clicker control for BlackBerry 6/7, like this: At

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.