1)嘿。我需要像素方面的帮助...如何在绘制功能中以更少的延迟绘制像素?当我画它们时,我的处理器使用率为 40%,这太多了。
protected override void Draw(GameTime gameTime)
{
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
spriteBatch.Draw(grasspixel, screenpos, Color.Red);
GraphicsDevice.Clear(Color.CornflowerBlue);
DrawGround(spriteBatch, 1024, 768, screenpos, grasspixel);
spriteBatch.End();
base.Draw(gameTime);
}
这是 DrawGround 函数:
public void DrawGround(SpriteBatch spriteBatch, int screen_X, int screen_Y, Vector2 screenPosition, Texture2D texture)
{
Vector2 tempVector = Vector2.Zero;
for (int i = 1; i <= screen_X; i++)
{
for (int j = 1; j <= screen_Y; j++)
{
if (earth[i, j] == 1)
{
tempVector.X = i;
tempVector.Y = j;
spriteBatch.Draw(texture, tempVector, Color.Blue);
}
}
}
}
在 DrawGround 中,我从数组中获取像素位置,然后将它们返回给 Vector2。
2)我需要每帧都画我的地图吗?
是否有特殊的缓冲区或类似的东西来做到这一点?对不起,如果我问一些愚蠢的问题,但我是 XNA 的新手。对不起,我的英语不好。