Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# MonoGame加载png文件_C#_Xna_Monogame - Fatal编程技术网

C# MonoGame加载png文件

C# MonoGame加载png文件,c#,xna,monogame,C#,Xna,Monogame,我试图在代码中引用png文件。在Visual Studio的解决方案资源管理器中,我将该项添加到名为“Content”的文件夹中,该文件夹位于默认的“MonoGameWindowsApplication1”文件夹中 我试过: Texture2D background = Content.Load<Texture2D>("background"); Texture2D background=Content.Load(“背景”); 及 Texture2D background=Con

我试图在代码中引用png文件。在Visual Studio的解决方案资源管理器中,我将该项添加到名为“Content”的文件夹中,该文件夹位于默认的“MonoGameWindowsApplication1”文件夹中

我试过:

Texture2D background = Content.Load<Texture2D>("background");
Texture2D background=Content.Load(“背景”);

Texture2D background=Content.Load(“Content/background”);
但它们都返回为空。我如何获得对图像的引用


这里是Visual Studio的屏幕截图,如果有帮助的话:

可以找到与您的问题相关的解决方案。您需要将内容/背景更改为24位或32位颜色格式。

您说得对!这就解决了!谢谢!:)我会将此作为答案发布,以便您可以将其标记为已解决。顺便说一下,24位颜色格式不起作用,因此它必须是32位颜色格式!
Texture2D background = Content.Load<Texture2D>("Content/background");