1
votes

I'm trying to get the position of the cursor by calling the mouse class and using the GetState method but the return value is always 0,0. I've searched everywhere and all the code looks the same on other examples. I've tried alternative ways of declare the class but I get the same results.

public void Update() {
    var ms = Mouse.GetState();
    cursorPos = new Vector2(ms.X, ms.y);
}
1

1 Answers

1
votes

If you are using Mono, it's possible that Mouse.GetState method is extended. On some past versions there was problems Mouse.SetState method, could be that also problem was also in Mouse.GetState... so I suggest you take latest Mono framework.

Or you can try to access directly to that method.

var ms = Microsoft.Xna.Framework.Input.Mouse.GetState();
var mp = new Point(ms.X, ms.Y);