ContentLoadException in MonoGame

后端 未结 5 681
夕颜
夕颜 2021-01-13 19:29

I\'ve been trying load a texture in MonoGame using Xamarin Studio. My code is set up as below :

#region Using Statements
using System;

using Microsoft.Xna.F         


        
相关标签:
5条回答
  • 2021-01-13 20:06

    Set the 'Build action' of the png file to 'Content' and set 'Copy to output directory' to 'Copy if newer'.

    You can bring up the properties window in Xamarin Studio by ctrl clicking the file and pressing properties.

    You shouldn't include the file extension.

    0 讨论(0)
  • 2021-01-13 20:08

    You need to add the file to the Content directory of your solution and set it to content / copy if newer in the properties window. It will then be copied to the output directory during the build process.

    Note that you can either use a precompiled XNB file (usually created with XNA game studio) or you can use raw PNG image files. If you use the latter you'll need to add the file extension in your code.

    0 讨论(0)
  • 2021-01-13 20:10

    Move Content folder to Assets and for each resource file set the 'Build action' to 'AndroidAsset' and set 'Copy to output directory' to 'Copy if newer'.

    0 讨论(0)
  • 2021-01-13 20:17

    Just use this way

    using (var stream = TitleContainer.OpenStream ("Content/charactersheet.png"))
    {
        characterSheetTexture = Texture2D.FromStream (this.GraphicsDevice, stream);
    
    }
    

    instead of

    texture = Content.Load<Texture2D>("player");
    
    0 讨论(0)
  • 2021-01-13 20:18

    To get it working just follow my instruction:

    Simple 2D game with Xamarin

    I know its little long but it works trust me, in case of additional questions feel free to ask :D regards Schreda

    0 讨论(0)
提交回复
热议问题