Keep the old position of mouse.Y in a variable then check if mouse.Y is less than the variable. If it is less than the variable then the scroll is moving upwards. Else it is moving down.
How to know if a rectangle in xna is moving up or down
Question
I'm developing a gui for my game using monogame, and im having hard times trying to figure out how
to implement a chat system,almost everything is pretty much done except for the scroller of the
chat window, so the scoller is a rectangle with an image, if i click on it and drag it will follow
the mouse Y position, i wanted to know how can i determine if the scoller is going up or down ,
positive or negative?
here it is the code:
Rectangle area3 = _chatScrollBoxScrollAreaRect;
if (area3.Contains(mousePosition))
{
if (mouseState.LeftButton == ButtonState.Pressed)
{
if (mousePosition.Y < (area3.Y + area3.Height) - 40)
{
scroll = true;
_chatScrollerRect.Y = mousePosition.Y;
}
}
any help is greatly appreciate!! Kind regards, Romulo Romero
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow