【发布时间】:2016-08-07 02:03:07
【问题描述】:
我的游戏菜单如下所示:
它的代码:
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
每个菜单项上的米色背景是碰撞命中框。
知道为什么会这样吗?
谢谢
【问题讨论】:
-
看起来图形与输入的缩放比例不同。你的
SpriteBatch.Begin电话是什么样的?您是否应用了转换矩阵?
标签: c# menu hover mouse monogame