Christian Boman Christian Boman - 10 months ago 46 Question

How to load textures after startup in XNA using

I've encountered a problem with my gameproject lately. When I load more than a certain number of textures (around 1000) at startup I recieve an error regarding memory (because I have to use 32-bit in XNA). I am self-taught and so have only basic knowledge of the "correct" ways to program a game. The project itself is getting very big and although I try to compress images together etc, I will have to use more than 1000 textures throughout the project.

My question, then, is: How can I load textures at other points in time than at startup in XNA, using (I'm not using classes at all that I'm aware of, so I hope to stay away from that if possible)

Thank's for any feedback on this!


So the answer seems a lot easier than I expected, if I'm doing it right at the moment(?).

I simply Load the content needed for all "Worlds" in the beginning of the game (in the Protected Overrides Sub LoadContent()) and then Dispose() and Load.Content() depending on what World is loaded later (in any Sub I choose):

TextureName = Content.Load(Of Texture2D)("")

If there isn't any problem I'm not yet aware of, this seem to do the trick and does not leave me with the memory error in the start.

Thank you Davor Mlinaric and Monset for helping me along