Jump to content

  • Log In with Google      Sign In   
  • Create Account

When do you get Mouse.getstate().X or Y as negative?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 mrhussain0334   Members   -  Reputation: 116

Like
0Likes
Like

Posted 22 September 2013 - 11:30 AM

I am creating a game in which I use a function:

int x()
{
    int px = 100;
    int pxend = 128;
    int xx = 0;
    for (int i = 0; i < 6; i++)
    {
        l = Mouse.GetState().X;
        if (l> px && l < pxend)
        {
            xx = px;
            break;
        }
        else
        {
            px += 128;
            pxend += 128;
        }
    }
    return xx;
}

And:

int y()
{
    int px = 100;
    int pxend = 128;
    int xx = 0;
    for (int i = 0; i < 4; i++)
    {
        l = Mouse.GetState().X;
        if (l > px && l < pxend)
        {
            xx = px;
            break;
        }
        else
        { 
            px += 128;
            pxend += 128;
        }
    }
    return xx;
}

 

But when I debug I get value a l as negative even though the debug is initiate after a click on theGameWindow screen. Sometimes it works fine sometime does not. I dont know why does it give me negative value. And when I used them with my Rectangle i get Rectangle.X and Rectangle.Y as0.


Edited by rip-off, 22 September 2013 - 12:54 PM.
Formatting


Sponsor:

#2 SeraphLance   Members   -  Reputation: 1362

Like
0Likes
Like

Posted 22 September 2013 - 12:25 PM

http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.mouse.windowhandle.aspx

 

This pretty much covers it.  You want to figure out where your (0,0) origin is.



#3 rip-off   Moderators   -  Reputation: 8202

Like
0Likes
Like

Posted 22 September 2013 - 12:55 PM

Please use [code] and [/code] tags, or the "code" tool in the WYSIWYG editor when pasting source code.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS