Estoy trabajando en el juego. Quiero resaltar un lugar en la pantalla cuando sucede algo.Rectángulo de dibujo con XNA
he creado una clase para hacer esto por mí, y encontró un poco de código para dibujar el rectángulo:
static private Texture2D CreateRectangle(int width, int height, Color colori)
{
Texture2D rectangleTexture = new Texture2D(game.GraphicsDevice, width, height, 1, TextureUsage.None,
SurfaceFormat.Color);// create the rectangle texture, ,but it will have no color! lets fix that
Color[] color = new Color[width * height];//set the color to the amount of pixels in the textures
for (int i = 0; i < color.Length; i++)//loop through all the colors setting them to whatever values we want
{
color[i] = colori;
}
rectangleTexture.SetData(color);//set the color data on the texture
return rectangleTexture;//return the texture
}
El problema es que el código anterior se llama cada actualización, (60 veces por segundo) y no fue escrito teniendo en cuenta la optimización. Tiene que ser extremadamente rápido (el código anterior congela el juego, que solo tiene código esqueleto en este momento).
¿Alguna sugerencia?
Nota: Cualquier código nuevo sería excelente (WireFrame/Fill son buenos). Me gustaría poder especificar el color.
¡Gracias! Funciona de maravilla. – Ben