madhu kumar
madhu kumar

Reputation: 810

why png file is not identified in this xna project?

png error

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

Answers (3)

Crumbs
Crumbs

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

jalgames
jalgames

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

Den
Den

Reputation: 1912

You need to add that file into content project instead.

Upvotes: 1

Related Questions