[SOLVED] - See linked post in the P.S.
I have a set of Texture2Ds generated in the Load method with this function:
Texture Generation:
private Texture2D[,] createTextureSet(TileInfo[,] map)
{
Texture2D[,] texSet = new Texture2D[map.GetLength(0), map.GetLength(1)];
using (SpriteBatch sprb = new SpriteBatch(GraphicsDevice))
{
for (int row = 0; row < map.GetLength(0); row++)
{
System.Threading.Thread.Sleep(10);
for (int col = 0; col < map.GetLength(1); col++)
{
RenderTarget2D renderer = new RenderTarget2D(this.GraphicsDevice, 300, 300);
System.Threading.Thread.Sleep(2);
GraphicsDevice.SetRenderTarget(renderer);
renderer.Name = map[row, col].buildings[0].buildingType;
GraphicsDevice.Clear(Color.Transparent);
sprb.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied);
sprb.Draw(TextureFromFile(resourceDirectory + @"Images\Tile Backgrounds\" + map[row, col].tileType + @"\" + map[row, col].tileBackground + ".png"), renderer.Bounds, Color.White);
sprb.Draw(TextureFromFile(resourceDirectory + @"Images\Buildings\" + map[row, col].buildings[0].buildingType + ".png"), (Vector2)map[row, col].buildings[0].pointWithinTile, Color.White);
sprb.End();
texSet[row, col] = renderer;
}
}
}
GraphicsDevice.SetRenderTarget(null);
return texSet;
}
The tiles are drawn on the screen using the following code:
Texture Rendering
for (int tx = -1; tx < 2; tx++)
{
for (int ty = -1; ty < 2; ty++)
{
gameSpriteBatch.Draw(mapTextureSet[gameCharacter.characterTile.tileX + tx, gameCharacter.characterTile.tileY + ty], determinePositionToDrawTile(gameCharacter, map[gameCharacter.characterTile.tileX + tx, gameCharacter.characterTile.tileY + ty], tx, ty, resizeX, resizeY), null, Color.White, 0f, Vector2.Zero, new Vector2(resizeX, resizeY), SpriteEffects.None, 0f);
}
}
These textures are then drawn on the screen based on where on the map the player is. The game runs fine, until the game window is resized by the user. After that, only the character sprite remains on the screen during the redraws, and the screen remains the default Color.BlanchedAlmond
background of my game. Any help is thanked in advance.
[ ! ] P.S. [ ! ]
Before marking this as a duplicate! I have looked at this and tried most of the applicable solutions from it, none of which have worked, so I assume that this error is deeper than that one.
Thread.Sleep
? \$\endgroup\$Random
correctly? See this answer. \$\endgroup\$TextureFromFile
method do? Also, my SO answer that you linked does seem to exactly describe the problem you are having. Did you try implementing "Option 3" from that answer? Can you show the code you used? \$\endgroup\$