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 doing 2D game using XNA framework 4.0. I'd like the game to have multiple levels. Where do I store the levels and how do I implement a scoring system for the game? Can I use XML for storing data for that levels and scores? Finally, is there any code samples for a multiple level game in Windows phone 7 using XNA 4.0?

share|improve this question
add comment

3 Answers

See the platformer kit on the app hub. Includes Xbox, PC, and WP7.

http://create.msdn.com/en-US/education/catalog/sample/platformer

It has examples of what you are asking (including XML levels).

share|improve this answer
add comment

Well, you can store games in the content folder (make sure to set them to compile:none in the item properties) and then load them using

[Microsoft.Xna.Framework.Storage.TitleLocation + Content.RootDirectory + file_name]

using something like StreamReader or XML (it also does not have to be in the content folder but just the game root directory). To load them, either hard code their names into the game or name the files like 1.level, 2.level, etc.

share|improve this answer
    
I don't think this is possible anymore in XNA4 on WP7. In previous versions you would use the StorageContainer.Path property along with normal System.IO to perform your file operations. In XNA Game Studio 4.0, we’ve moved in a direction more aligned with the IsolatedStorage APIs where StorageContainer now exposes many file operations as methods such as CreateFile, GetDirectories, and FileExists. blogs.msdn.com/b/nicgrave/archive/2010/07/23/… –  Roy T. May 23 '12 at 16:45
    
I forget, but in any case you can just write a generic content reader –  CobaltHex May 24 '12 at 1:16
add comment

You can store arbitrary XML files in the XNA asset manager but remember to set the compiling off for those files (so the remain as plain text and don't get saved as binary files). You can see an example in my open source game Urban Race. It's 3D but the concept still applies, I read XML for the levels at runtime, just what you want.

share|improve this answer
    
-1 this won't work in WP7, you actually do have to compile the XML files and then use the XML content importer to read them. –  Roy T. May 23 '12 at 8:16
    
Didn't know that. –  David Saltares Márquez May 23 '12 at 8:23
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.