Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

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

4: Adsense

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   

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


#2 SeraphLance   Members   

2574
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   

10884
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.