Reputation: 810
why png file in not identified in this program?
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Texture2D box;
}
//this part is showing error that next is not identified.
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
box = Content.Load<Texture2D>("next");
}
Upvotes: 0
Views: 113
Reputation: 81
The problem you are having is that you have added the PNG file to the project solution (in your case, the project named ImageZoomInOut). To solve the problem you are having simply add the PNG file to the ImageZoomInOutContent(Content). You should continue to add all content-related material (such as Models, Textures and sounds) there as well.
The ContentProcessor in XNA expects all content it works with be in a predetermined folder. If you use explorer to look through your project folders you will see a folder named ImageZoomInOutContent, once you have added the content via Visual Studios and successfully built the App it will be populated with the next.png (the original file) and next.xnb (a serialized file). This xnb file is the file used in your app after it has been processed.
Upvotes: 2
Reputation: 789
For doing that, right-click on the content-project in the solution explorer and select Add->Existing. After that, you can select your image.
Upvotes: 1