Sushisource

Hey everyone, small problem here.

I've managed to get XNA to run inside of a Panel in my windows form, but my problem is that I can't figure out how to load textures to sprites, since my form does not extend Game.

And even when I make a game class, it still says that it can't find my image file, even though I am quite sure it is there.

When I look at the debugging process further, I find that it is looking for a file called
(imagename).xnb

What is this file And why is it not being created like it should be Any help would be greatly appreciated.

This is the line in trouble (pixel, obviously, is the name of my image):

SpriteTexture = content.Load<Texture2D>("pixel");


Re: XNA Game Studio Express Content - XNA + SpriteBatch in a windows form

Jim Perry

Is the graphic part of the project and marked as a content pipeline asset Add the graphic to the project under the Properties window the XNA Framework Content property should be set to True. Also make sure the Asset Name property is "pixel" as you're using in the code.




Re: XNA Game Studio Express Content - XNA + SpriteBatch in a windows form

Sushisource

See, that's the problem, I need to learn how to establish an XNA content pipeline, since this project does not have one, because it is originally just a WindowsApplication.

So how can I set up the whole XNA content pipeline deal for a windows app




Re: XNA Game Studio Express Content - XNA + SpriteBatch in a windows form

Jim Perry

Is there a reason you can't create a Windows Game project and move all your code into it That would be the easiest solution, though it might require some rework. It would probably be less than trying to hack in content pipeline support into the existing app though.




Re: XNA Game Studio Express Content - XNA + SpriteBatch in a windows form

Sushisource

Either way I think it would be about the same amount of work, because if I moved it over to an XNA game I would have to get all the windows control stuff working, which is suppose wouldn't be too difficult.

However, I am simply curious as to how to do it, even just as a learning experience.




Re: XNA Game Studio Express Content - XNA + SpriteBatch in a windows form

Jim Perry

You can use Windows Forms in an XNA project with no problem, no code changes should be needed. The only thing you need to change is where XNA renders to, and I've seen projects that have done this.




Re: XNA Game Studio Express Content - XNA + SpriteBatch in a windows form

Sushisource

Okay, well, I'll probably do that.

But just in case, is there anyone who can explain how to integrate an XNA content pipeline into a windows app for me




Re: XNA Game Studio Express Content - XNA + SpriteBatch in a windows form

Shawn Hargreaves - MSFT

The content build process is exposed as an MSBuild task, so you can use any MSBuild functionality to automate running this as part of the build. Looking at the default targets used in our XNA game projects should give you some idea where to start with that.

You won't get any of the VS UI around setting up content unless your project uses the XNA project flavor, though, so you need to start with an XNA project type to enable that.