@lozzajp wrote:
Hey all,
I have roughed up a system that allows you to load assets per "level". It could do with loads of improvement but I was hoping to get some feedback if I am heading in the right direction.
Look in the repo at Assets/assets.txt and you will see a simple text format of an asset path along with a name you can identify it by (split by comma). Also some header info of the level name and the type of asset being loaded.
The basic idea is this, when you start a level you can call Load("levelname") and it will load all assets it needs for that level, if you load another level then it unloads the previous level etc. You can then access the assets by name/id using the manager classes opposed to the old content way (basically a wrapper). ie
var background = GetGraphicsManager.LoadTexture("mainmenubackground"); // use background in draw etc.
I understand you would always have to map your content directories to the assets.txt list but that can be automated and as well the trade off by just referring to a name or id might well be worth it.
Also I understand a large project this may not be the way to go, but something like a 2D platformer with screen transitions etc may suit well.
Some points I am interested in for feedback:
AssetLoader.cs is a static class and keeps a reference to the original Content instance (passed in from game1)
The managers get this reference but then create their own ContentManager from the passed in content.ServiceProvider
The managers keep a list of Assets (struct of 2 strings) at all times
On level load the managers and their contentmanagers are emptied and nulled and recreated.
Would there be a benefit to preload all the text file in a List of level names?
Any more comments
Posts: 1
Participants: 1