Be a Supporter!

Weird Cursor Lag Xna/c#

  • 678 Views
  • 1 Reply
New Topic Respond to this Topic
Thegluestickman
Thegluestickman
  • Member since: Mar. 16, 2007
  • Offline.
Forum Stats
Member
Level 13
Game Developer
Weird Cursor Lag Xna/c# 2012-04-29 21:24:45 Reply

I'm making a menu in XNA; and to solve clunky input via arrow keys, I thought I would use mouse input. I got everything to work perfectly, then I tried to click on something specific and nothing happened. To troubleshoot, I drew an image where the cursor rectangle is supposed to be. As you can see in the image below it's nowhere near my mouse.

The menu update calls a mouse class to update the mouse position and place it within bounds of the screen. The mouse class also has a rectangle that updates based on the mouse position, but it updates almost 200 pixels away. The mouse moves fine in game, it's just the rectangle is in a weird position.

public void Update(GameTime gameTime)
    {
        oldmouse = currentmouse;
        currentmouse = Mouse.GetState();
        Position.X = currentmouse.X;
        Position.Y = currentmouse.Y;
        //Some other boundary code that's not essential
        clickRectangle.X = (int)Position.X;
        clickRectangle.Y = (int)Position.Y;
    }

I don't see a problem with the code. Is there something else I have to do?

I should also mention it sometimes draw nearer to the actual cursor and sometimes farther away. The cursor only drew to my actual cursor once before it stopped working. Note in the picture how they are in two different places.

Weird Cursor Lag Xna/c#


To protect the world from devastation.
kidd25 is the best Newgrounder ever.

BBS Signature
Thegluestickman
Thegluestickman
  • Member since: Mar. 16, 2007
  • Offline.
Forum Stats
Member
Level 13
Game Developer
Response to Weird Cursor Lag Xna/c# 2012-04-30 10:45:53 Reply

Well I figured it out... Stupid me.

Early in my menu development I inherited the "Game" class from XNA. I forget why, I think it had to do with getting certain method to work or something. I guess I had removed the code that need the inheritance and kept the inheritance which screwed up my update method. It wanted to override it but I didn't do that. Anyway I removed the inheritance and it worked fine.

Doi.


To protect the world from devastation.
kidd25 is the best Newgrounder ever.

BBS Signature