Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

My main goal is avoid using an external program like SpriteSheetPacker.

I would like to just use sequenced PNGs and have the sprite sheets be made, updated, and saved automatically when I build my game.

Edit: The old answers I upvoted, but I updated the question and specifically asked how to do this automatically with the Content Pipeline. Please do not give an answer that involves using an external program.

share|improve this question
1  
Coming back four months later and changing your question completely is kind of poor form. You should have created a new question. –  Andrew Russell May 27 '11 at 6:38
    
I only changed it to completely disambiguate it. You see I asked for something that would automatically update by itself when the game was launched(build). If you read my earlier version, you will see I am asking the same thing, except I have narrowed down what actually needs to happen. –  AttackingHobo May 27 '11 at 16:42
    
Launch-time and build-time are two very different things. Your original question actually implied that you wanted to monitor the files in question and reload them automatically at run-time, which is extremely different again. –  Andrew Russell May 28 '11 at 2:37
    
If you check out the comments I put on my answer, you'll find enough information to also answer your updated question. –  Andrew Russell May 28 '11 at 2:40

2 Answers 2

Breaking down what you want to do into solutions:

  1. You need some way to watch the file system to trigger this process. Polling it or using FileSystemWatcher come to mind as appropriate solutions. (If this is for some kind of editor, I personally find assigning a hotkey is preferable.)

  2. You need a way to actually create sprite sheets. Googling around will probably find something. Nick Gravelyn's Spritesheet Packer that bearcdp mentioned is probably more fully-featured, but I'm not sure that it is integrated into the content pipeline - the one in the XNA Sprite Sheet sample is.

  3. To create XNA's native XNB files you need to use the Content Pipeline. This requires you have XNA Game Studio installed on the end-user machine. You can invoke the content pipeline at runtime, and a good example of this to get you started is the Winforms 2 XNA sample.

  4. You can then load those XNB files with ContentManager as normal (and unload the old ones that you aren't using). I think the Winforms 2 sample has some discussion of your various options for caching and so on.

share|improve this answer
    
3. sounds good, but that link leaves much to be desired in how to actually accomplish what I am trying to achieve. –  AttackingHobo May 27 '11 at 2:39
    
@AttackingHobo That link was related to your original question, which implied that you wanted to do this when the files changed (ie: automatically at runtime), rather than simply at build-time. To do it at build time, simply create/locate and use an appropriate content pipeline extension. Like the one in the Sprite Sheet sample that I linked. –  Andrew Russell May 27 '11 at 6:41
    
Also: note the ContentProcessorContext.AddDependency method, which gives you a mechanism for detecting changes to files (eg: sprite images) that are not directly referenced by your content project. –  Andrew Russell May 27 '11 at 6:45

Are you talking about runtime as in while running on the Xbox? If so, no. But if you are talking about as part of your development process, then you could add a special content pipeline class, or at the most basic, a simple custom build step that runs a tool that updates image files needed.

Custom build steps allow you to specify the output files that should be checked to see if they need to be updated or not. You'll probably need a directory with standard naming schemes for the individual frames of an animated sprite, and a text file with the properties of the spritesheet to be parsed by your tool and also double checked for being up-to-date by MSBuild.

Check out the Spritesheet Packer by Nick Gravelyn for the example of modifying image data and outputting it. It's not what you're looking for, but it covers similar ground.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.