2015-02-24 39 views
0

我几天前开始使用monogame编程c#。 今天我收到了一个错误,提示“无法将资源加载为非内容文件”。 这是代码,我需要很多帮助。 列出纹理;MonoGame:无法加载资产(我尝试了所有的东西)

public Game1() 
     : base() 
    { 
     graphics = new GraphicsDeviceManager(this); 
     Content.RootDirectory = "Content"; 
    } 
    protected override void Initialize() 
    { 
     base.Initialize(); 
    } 
    protected override void LoadContent() 
    { 
     spriteBatch = new SpriteBatch(GraphicsDevice); 
     // the below line errors 
     textures.Add(Content.Load<Texture2D>("Lol")); 

    } 
    protected override void UnloadContent() 
    { 
    } 
    protected override void Update(GameTime gameTime) 
    { 
     base.Update(gameTime); 
    } 
    protected override void Draw(GameTime gameTime) 
    { 
     GraphicsDevice.Clear(Color.CornflowerBlue); 

     base.Draw(gameTime); 
    } 
} 

回答

1

解决

如何?

  1. 在内容1下创建一个子文件夹。
  2. 称之为“资产”
  3. 右键单击图像文件,然后右键单击
  4. 属性 - >复制到输出 - >复制始终
  5. 转到主类,并设置RootDirectory为“Content.RootDirectory = @“Content \ Assets”;“

END

附: :每次添加文件时,重复第3步和第4步

相关问题