나는 게임 중입니다. 뭔가 일이 생길 때 화면의 한 지점을 강조하고 싶습니다. XNA로 사각형 그리기
나는 사각형을 그리는 코드를 조금 나를 위해이 작업을 수행하는 클래스를 생성하고, 발견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
}
문제는 그 위의 모든 갱신 호출되는 코드 (1 초에 60 번) , 최적화를 염두에두고 작성된 것은 아닙니다. 그것은 극도로 빠를 필요가 있습니다 (위의 코드는 지금은 스켈레톤 코드 만 가지고있는 게임을 멈추게합니다).
제안 사항?
참고 : 새로운 코드는 모두 훌륭합니다 (WireFrame/Fill은 모두 괜찮습니다). 색상을 지정하고 싶습니다.
감사! 매력처럼 작동합니다. – Ben