• Advertisement
Sign in to follow this  

[XNA] Resource Storage

This topic is 2732 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If you have numerous resources(sound files, sprites, textures, models, etc.) and you don't want to leave them in a folder where the user can access them, what do you do with them? Is there a way to build them into the executable or is there a way to pack them in a compressed archive file and then use some code to extract them as needed?


For example,

I have spritesheet1.png, spritesheet2.png, ...., spritesheet30.png, etc.
and I don't want to leave them alone in content\sprites.

Is there a way I can do sprites.pak or just build them into the executable?

Share this post


Link to post
Share on other sites
Advertisement
hi, yes both options are viable. You can use a zip lib like zlib, bzip2, or some other zip libraries to zip your files. If not you can also just pack all your files into a .pak file. Here is an article hosted on gamedev which talks about pak files in general. You can use it as a reference and customize to your needs.

http://www.gamedev.net/reference/programming/features/pak/

Lastly you can also use a pak file along with a zip library.

regards

Share this post


Link to post
Share on other sites
If you use the content pipeline to import and process your image files, then they'll already be stored in a compressed binary format (as a .xnb file). So it's not like anybody will be able to just double-click on them and open them.

If you wanted you could still bundle up your .xnb files in a .zip/.pak file. You would just need to unzip the .xnb files and then you could load them normally with a ContentManager.

Share this post


Link to post
Share on other sites
So you couldn't access them while they were still compressed? I believe unzipping them to be loaded by the contentmanager would be defeating the purpose of hiding them from the user to begin with.

Share this post


Link to post
Share on other sites
Not with the default ContentManager implementation. You can do it if you subclassed it with an overridden OpenStream method. You would just have to handle loading the packfile and setting up a memory stream for the specified asset.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement