The Load method is a method which can be used to load content either from a XNB (if using content pipelines) or from raw file if FlatRedBall supports the file format. For more information on the Load method and how FlatRedBall caches content, see the FlatRedBall Content Manager wiki entry.
The Load method supports either absolute or relative file names. In other words, both are valid (assuming the files exist):
--or--
The Load method will prepend FileManager.RelativeDirectory if the argument file is relative. In other words, the following two are equivalent:
--and--
FileManager.RelativeDirectory defaults to the project's Content directory (the location where the Content project copies/builds files if using XNA). Therefore, if redball.bmp were present at the root of the content folder, then "content\redball.bmp" would be used to load the file.
If using an XNA project, most files are added to a Content project. Any file added to the Content project must be loaded with the "content/" prefix. For example, if a file "redball.bmp" is added to the root of the Content project, then the call to load it would be:
The Load method supports caching and returning cached content to improve speed and reduce memory usage. To understand this, consider the following
The Load call performs the following logic:
Look for a ContentManager with a name matching the contentManager argument.
If no contentManager is specified, the "global" ContentManager is used.
If no matching ContentManager is found, create one.
Search the ContentManager for an instance that has a matching name.
If the content is found, return the existing instance. This saves time loading content and reduces RAM usage.
If the content is not found, attempt to load it.
For more information on how file names are stored, see the ContentManager.IsAssetLoadedByName page.
The Load method can give you disposables that have been added through AddDisposable. This means that you can use FlatRedBallServices as a cache for content that comes from disk as well as content created dynamically. For example, the following method would work: