Would you like to react to this message? Create an account in a few clicks or log in to continue.

    XNA Input states

    avatar
    Admin
    Admin


    Posts : 77
    Join date : 2009-07-28

    XNA Input states Empty XNA Input states

    Post  Admin Wed Feb 03, 2010 4:19 pm

    Summary

    • Input devices supported in XNA include the keyboard, mouse, and Xbox 360
    controller.

    • The Xbox 360 has several analog inputs that allow for varying degrees of input
    from a single button.


    Code:
    //Update time since last frame and only
                //MOUSE INPUT
                MouseState ms = Mouse.GetState();
                if (ms.LeftButton == ButtonState.Pressed)
                    ringpos = new Vector2(ms.X, ms.Y);
                //KEYBOARD INPUT
                KeyboardState ks = Keyboard.GetState();
                if (ks.IsKeyDown(Keys.Z))
                    ringpos.Y += speed.Y;
                if (ks.IsKeyDown(Keys.S))
                    ringpos.Y -= speed.Y;
                if (ks.IsKeyDown(Keys.Q))
                    ringpos.X -= speed.X;
                if (ks.IsKeyDown(Keys.D))
                    ringpos.X += speed.X;

      Similar topics

      -

      Current date/time is Mon May 20, 2024 7:52 am