user1621127
user1621127

Reputation: 301

How to create a tooltip in XNA?

i've just started to learn XNA and i want to make a tooltip? I've googled but not found any answer.

Thanks in advance.

Upvotes: 0

Views: 472

Answers (1)

Cyral
Cyral

Reputation: 14153

MouseState ms = Mouse.GetState();

if (ms.X == YourPoint.X && ms.X == YourPoint.X)
{
   SpriteBatch.DrawString(ToolTipFont, "A tooltip!", new Vector2(ms.X,ms.Y),Color.White);
}

You could and also should use Rectangle.Intersects for an easy way to see if the mouse is over it. Ex:

MouseRect = new Rectangle(ms.X,ms.Y,1,1) 
if (MouseRect.Intersects(YourPoint.X,YourPoint.Y,WidthOfArea,HeightOfArea))

Upvotes: 1

Related Questions