ich ein Menü für mein Spiel haben, die wie folgt aussieht:C#/monogame: Menüpunkte ändern Farbe auf Maus Hover Ausgabe
den Code für sie:
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);
}
Derzeit Wenn ich mit der Maus über einen Menüpunkt gehe, wird der darüber liegende rot hervorgehoben. ZB:
https://gyazo.com/472352a190398785f81854387902bf7d
Der beige Hintergrund auf jedem Menüpunkt ist die Kollision Hit-Box.
Irgendeine Idee, warum das passiert?
Dank
Sieht so aus, als ob die Grafiken unterschiedlich zum Eingang skaliert sind. Wie sieht Ihr 'SpriteBatch.Begin' Anruf aus? Haben Sie eine Transformationsmatrix angewendet? – craftworkgames