Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Ive a sprite that I want to control with keys

$
0
0

@Bulent_Gozen wrote:

if (Keyboard.GetState().IsKeyDown(Keys.Down))
{

             positionoutercursor.Y += 40 ;
         }
         if (positionoutercursor.Y >=260)
        {
            positionoutercursor.Y = 260;
        }

        if (Keyboard.GetState().IsKeyDown(Keys.Up))
        {

            positionoutercursor.Y -= 40;
        }
        if (positionoutercursor.Y <= 15)
        {
            positionoutercursor.Y = 15;
        }

But when i press up or down the sprite moves much more than i want. The problem is that I want it move only 40 pixels to up or down each time I press these keys. I dont want it to continue adding 40 all the time according to time I press the key. Anyone can help me with this very simple question? (It ddoent pass the board limits I put but move 80 or 120 pixels each time)

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles