2012-10-10 40 views

回答

1
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); 
} 

您可以也應該使用Rectangle.Intersects來查看鼠標是否在其上。例如:

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

完美!謝謝! – user1621127

相關問題