xna 4.0 and loading images fails

落爺英雄遲暮 提交于 2019-12-02 03:20:35

In XNA Images are compiled .xnb files and not .png or .jpg

XNA 3.0 || XNA 3.1
You add your Content to the Content folder within your project

XNA 4.0
You have a Content Project and you add a Content Reference in your current project

Also Make sure you set the properties of the images: Right Click on Content Item -> Properties -> Set the following

  • Build Action: Compile
  • Content Importer/Processor: Texture - XNA Framework (Textures)
  • Content Importer/Processor: Sprite Font Description - XNA Framework (Fonts)
  • Do not copy

Additionally remember to rebuild solution after adding new resource to content project.

In XNA you typically load processed files (xnb files). You'd add a content project to your solution, and reference that in your main game project (usually this is set up when you create a new game).

You add your files (assets) in there. When your game is built the content project is built, which processes your assets, producing xnb files, which is what the ContentManager.Load method wants.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!