Hi all,
I'm imagining this is a very simple problem, but I seems to be unable to solve it despite many hours trawling the net and various tutorials.
Basically, I have a class file sepearate from Game1 but in the same namspace and I want to load some content, but all I get is the error above.
I've tried various ways of referencing the content, contentManager.Load, Game.Content.Load etc... etc... but they all just give errors.
Could someone please tell me what I am doing wrong and how I can load content outside of the Game1 class??
Thanks in advance for the help. The code for the class is currently as follows:
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace SinsoftheFounders
{
class WorldGenerator
{
private landScape[ landScapes;
public dungeon[ dungeons;
public WorldGenerator(string lsfFile)
{
parseLSFfile(lsfFile);
}
public struct landScape
{
private int width;
private int height;
private Texture2D heightMap;
private string name;
private string textureSet;
public landScape(int height, int width, string heightMap, string name, string textureSet)
{
this.width = width;
this.height = height;
this.heightMap = Content.Load<Texture2D>(heightMap); Here is the problem line!!!
this.name = name;
this.textureSet = textureSet;
}
}
public struct dungeon
{
private int width;
private int height;
public dungeon(int height, int width)
{
this.width = width;
this.height = height;
}
}
private void parseLSFfile(string lsfFile)
{
string[ fileLines = FileReaderUtil.SplitFileByLine(lsfFile);
int areaNumber = fileLines.Length;
for(int index = 0; index < fileLines.Length; index++)
{
string[ items = fileLines[index].Trim().Split(',');
landScapes = new landScape[fileLines.Length];
landScapes[index] = new landScape(Convert.ToInt32(items[2]), Convert.ToInt32(items[3]), items[4], items[0], items[1]);
}
}
}
}