[英]C#/Monogame: Menu Items Change color on Mouse Hover Issue
我的游戲菜單如下所示:
它的代碼:
for (int i = 0; i < menuItems.Length; i++)
{
//create collision detectiong rectangle x and y pos same as text below, length and width based on font.
collisionRectangle = new Rectangle(100, 300+(space*i), menuItems[i].Length*10, 24);
//determine if menu posisiton is on the current for loop draw position or if the mouse is hovering the current item. If it is, color the text red
if (mpos == i || collisionRectangle.Contains(mousePoint))
{
spritebatch.DrawString(basic, menuItems[i].ToString(), new Vector2(100, 300 + (space * i)), Color.Red);
}
//Otherwise the text is not selected and is black
else
spritebatch.DrawString(basic, menuItems[i].ToString(), new Vector2(100, 300 + (space * i)), Color.Black);
}
}
else
{
//Output the result based on user choice
spritebatch.DrawString(basic, result.ToString(), new Vector2(100, 300), Color.Black);
}
目前,當我將鼠標懸停在一個菜單項上時,它上方的菜單項將以紅色突出顯示。 例如:
https://gyazo.com/472352a190398785f81854387902bf7d
每個菜單項上的米色背景都是碰撞命中框。
知道為什么會這樣嗎?
謝謝
我已經解決了我的問題:事實證明調試框未對准。 將collisionRectangle y值設置為(300-space)解決了我的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.