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.

I am wondering about in-game level design. My current situation revolves around Tiled - I have many different layers with different types of objects in them (for anyone who isn't familiar with Tiled, an object is nothing more than a coordinate with arbitrary properties assigned to it).

I am currently re-compiling the game every time I make a little change to my map file to see if everything is positioned properly. Is there a way for me to have my game automatically re-load the level if a map file change is detected? Does XNA even allow for this, or does the way the content pipeline work not allow for dynamic content in such a way? Any tips or suggestions are absolutely welcome.

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

I assume your map files are processed via the Content Pipeline, and then loaded at runtime with Content.Load. You have two options:

  • Save your maps as a XML file, via IntermediateSerializer.Serialize. Then, at runtime, you can read them with IntermediateSerializer.Deserialize to see the changes.
  • This is a tougher one: calling MSBuild at runtime to recompile your files into proper XNBs, and reloading them with the ContentManager. This sample does that.
share|improve this answer
    
Between the two, I'm sure I'll be able to sort something out. Thank you! –  Christopher Horenstein Nov 21 '10 at 1:01
add comment

You could also use Karvonite if you want to get this up and going really fast.

It's an agile persistence framework. I'm not sure if the new version will work on windows phone 7 or xbox.

You would create a persistence definition with their persistence editor (it's pretty easy, you just import the assembly and check the fields/properties on the classes/structures you want persisted) You initiate an ObjectSpace in code and add/remove/get objects from it. (these objects are persisted)

If you could create an abstraction so that the tile engine or whatever it is you call it doesn't care exactly how it gets the map, just that it gets the one it asked for. Then you can go back and use the XmlSerializer or the Intermediate one. (whichever you prefer) All you'd have to do to implement those other serializers is create another implementation of the abstraction (an interface or abstract class).

I think there is an example of how to build content at runtime on the XNA creator's club website. It might not be built with the latest framework though. That way you could keep your old code if you already use the content pipeline. Here's the link : Winform Series 2: Content Loading

share|improve this answer
    
I feel a bit silly asking this, but can you describe what you envision the workflow using this framework to be? It sounds really neat, but I am not sure how to approach it. –  Christopher Horenstein Nov 23 '10 at 23:54
1  
Well, you define the serialization in their persistence editor. (it really easy, you just import your object assembly and check some boxes on the structures/classes and the fields/properties you want persisted) Once you've done that, you can just initialize an object space that will serialize/deserialize your objects. It's pretty neat and fast to get up and running. –  Michael Coleman Nov 24 '10 at 1:54
1  
You can also look at this project on codeplex for a better example of how to build content outside of visual studio. (xnadevru.codeplex.com/…) –  Michael Coleman Nov 24 '10 at 2:07
add comment

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.