gpt4 book ai didi

xna - SpriteBatch 不绘制到屏幕

转载 作者:行者123 更新时间:2023-12-02 22:20:55 24 4
gpt4 key购买 nike

当游戏重置但 spritebatch 没有绘制时,我试图在屏幕上绘制一个快速加载的 Sprite 。我在 game.spritebatch.begin(); 上设置了一个断点,当我逐步执行时,没有绘制任何内容。有什么想法吗?

这是我的重置函数

public void Reset()
{
loadingScreen = game.Content.Load<Texture2D>("Textures\\loadingScreen");
game.spriteBatch.Begin();
game.spriteBatch.Draw(loadingScreen, Vector2.Zero, null, Color.Black, 0.0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0f);
game.spriteBatch.End();
cameraPosition = original_cameraPosition;
players.Clear();
furthest = 0;
enemies.Clear();
LoadEnemies();
ActivatePlayers();
}

最佳答案

您可能没有在正确的位置进行轮询。纹理重置(loadingScreen = game.Content.Load<Texture2D>("Textures\\loadingScreen")应该只执行一次,否则是资源的巨大浪费。

另一方面的渲染代码:

    game.spriteBatch.Begin();
game.spriteBatch.Draw(loadingScreen, Vector2.Zero, null, Color.Black, 0.0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0f);
game.spriteBatch.End();

这需要不断轮询,否则它只会呈现几毫秒,之后您将无法看到它。将渲染代码放在渲染方法中,它应该可以正常工作。

关于xna - SpriteBatch 不绘制到屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13715999/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com