【发布时间】:2014-08-24 22:37:31
【问题描述】:
我正在为学校制作一个游戏,里面有 3 个小游戏我尝试运行它说的游戏
"An unhandled exception of type 'System.NullReferenceException' occurred in Summer Assignment.exe"
当我从类中取出加载内容的行并且我之前使用过类时,游戏运行良好,所以这里的问题不是代码
class Quiz
{
QuizQuestion no1;
ContentManager theContentManager;
SpriteBatch thespriteBatch;
int question = 0;
public void initialize()
{
no1 = new QuizQuestion();
}
public void LoadContent()
{
no1.LoadContent(this.theContentManager);
}
在我从加载内容方法加载内容的类中是
public void LoadContent(ContentManager theContentManager)
{
font = theContentManager.Load<SpriteFont>("Font2");
}
该类已在主游戏类中正确加载,我在添加下一个类之前运行它以确保
【问题讨论】: