Create xna resource files at runtime?

Started by
1 comment, last by Kaze 11 years, 8 months ago
Is it possible to compile images or sounds into xna resource files at run time, for example so the game level editor could have new tiles added without having to recompile?
Advertisement
There's two things you can do for loading images, and only one, vastly unpreferred method for everything else.

1) You can load images into textures using Texture2D.FromStream(). It only loads jpegs, pngs, and bitmaps if I recall correctly. Any other format you will need to load yourself and manually set into a texture.

2) The other option is to include the XNA framework with your level editor, so you can invoke the content pipeline at runtime. This option is laughable, really, because it would require your end users install the xna framework, c# express (can't install xna without this), and the full .net 4.0 framework (ditto). In total, that's a few gigabytes of data which is relatively unrealistic to expect of your users and one of the main criticisms I ultimately have with XNA. Sounds, Sprite Fonts, Meshes, etc all would require this option to compile into xnb files at runtime as the Content Pipeline is not included in the standard runtime.

I never looked into it but there may be third party file converters out there that you may be able to utilize.
Option #2 is workable since I don't intend to distribute the content editors with the game.

In xna I have found both the content manager annoying and integrating a xna window with winforms takes a lot of workaround solutions.

With both I understand xna was made with consoles in mind but even your exclusively targeting the xbox 360 isn't it a given that you would want to make a level editor if your making anything more complicated than pong or tetris.

This topic is closed to new replies.

Advertisement