所以..到目前为止,我的尝试是这样的,游戏并没有延伸:
这就是我这样做的方式:
我声明了这个变量。
RenderTarget2D renderTarget;
在我的 game1 构造函数中,我有这个:我也在这里尝试了实际的屏幕分辨率,同样的事情。
graphics.PreferredBackBufferWidth = 96;
graphics.PreferredBackBufferHeight = 160;
在我的初始化中,我有这个:
renderTarget = new RenderTarget2D(GraphicsDevice, GraphicsDevice.PresentationParameters.BackBufferWidth,
GraphicsDevice.PresentationParameters.BackBufferHeight, false,
GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24);
我这里有这个功能:
protected void DrawSceneToTexture(RenderTarget2D renderTarget)
{
// Set the render target
GraphicsDevice.SetRenderTarget(renderTarget);
GraphicsDevice.DepthStencilState = new DepthStencilState() { DepthBufferEnable = true };
// Draw the scene
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp,
DepthStencilState.None, RasterizerState.CullCounterClockwise);
switch (gameState)
{
case GameStates.Menu: { menuState.Draw(spriteBatch); break; }
case GameStates.Playing: { playingState.Draw(spriteBatch); break; }
case GameStates.GameOver: { gameOverState.Draw(spriteBatch); break; }
}
spriteBatch.End();
// Drop the render target
GraphicsDevice.SetRenderTarget(null);
}
我的绘图方法如下所示:
DrawSceneToTexture(renderTarget);
GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend,
SamplerState.LinearClamp, DepthStencilState.Default,
RasterizerState.CullNone);
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, actualScreenWidth, actualScreenHeight), Color.White);
spriteBatch.End();
base.Draw(gameTime);