我无能为力来解释这个问题。
这是我的主要绘制方法。如果我改变
controls.Draw(spriteBatch);
spriteBatch.End();
spriteBatch.Begin();
至
controls.Draw(spriteBatch);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate, null, null, d, rs);
块完美地绘制,除了在屏幕上没有绘制控件或文本。
d = new DepthStencilState(); //Class level
d.DepthBufferEnable = true;
d.DepthBufferWriteEnable = true;
GraphicsDevice.DepthStencilState = d;
rs = RasterizerState.CullNone;
GraphicsDevice.RasterizerState = rs;
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Cyan);
// need to do this on reach devices to allow non 2^n textures
GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp;
//spriteBatch.Begin(SpriteSortMode.Immediate, null, null, d, rs);
if (gameState == State.BREAKOUT)
{
wallBlock.Draw(camera);
if (firstBlocks.Count < 49)
{
foreach (Block block in secondBlocks)
{
block.Draw(camera);
}
}
foreach (Block block in firstBlocks)
{
block.Draw(camera);
}
ball.Draw(GraphicsDevice, camera.View, camera.Projection, spriteBatch);
spriteBatch.Begin(SpriteSortMode.Immediate, null, null, d, rs);
controls.Draw(spriteBatch);
spriteBatch.End();
spriteBatch.Begin();
if (ball.scoreMultiplier <= 1)
{
spriteBatch.DrawString(
scoreFont,
"Score: " +
scoreDiff +
"\n Lives:" +
ball.lives,
new Vector2(100, 10),
Color.Black);
}
else
{
spriteBatch.DrawString(
scoreFont,
"Score: " +
scoreDiff +
"x" +
ball.scoreMultiplier +
" multiplier!" +
"\n Lives:"
+ ball.lives,
new Vector2(100, 10),
Color.Black);
}
spriteBatch.End();
}
}