@jamie_yello wrote:
I know a while back I was passing 'Content' to my custom classes just fine, even setting a private ContentManager object to the passed one. Now, if I attempt
ImagePool image_pool = new ImagePool(Content);
// The error is hereclass ImagePool { ContentManager content; List<ImageSet> image_sets = new List<ImageSet>(); public ImagePool(ContentManager content_) { content = content_; }
I get
A field initializer cannot reference the non-static field, method, or property 'Game.Content'
I don't really want to ruin my neat code with globals. My ImagePool class is meant to share and manage resources, so one sprite isn't using a separate copy of the same Texture2D in memory as another. The outside program just passes a string to the image pool, and the ImagePool (should) load it itself.
Posts: 4
Participants: 3