0
\$\begingroup\$

I am developing an RPG for Windows Phone 8 using XNA. I have a map screen and a fight screen. I want to use XNA for both to utilize the graphics helpers and because XNA is awesome. My question is, how do I save the map state between the two screens? That is , how do I save the location of the PC and the enemies when I travel back and forth between the two screens?

\$\endgroup\$
  • \$\begingroup\$ You either need to be more specific to your problem or you need to read some beginner level programming books. Likely both. \$\endgroup\$ – indeed005 Mar 7 '13 at 3:00
  • \$\begingroup\$ @indeed005 I think it was pretty clear. :) \$\endgroup\$ – Vaughan Hilts Mar 7 '13 at 3:13
0
\$\begingroup\$

If you're using some kind of State Management this will just happen automatically. You'd have two states or screens in the case of the Microsoft XNA sample.

GameplayScreen

We can call this your gameplay screen state which would compromise of a few things but for your case you could just have the map on this screen and other things like input for moving around the map and logic for updating entities on this map. You wouldn't include things that aren't related to your "overworld" or "map" display. Things like a mini-map may go here but the decision is yours on how you separate your logic. Ideally, a menu would be another state but that's another discussion. However, what you should take away from this is no combat takes place inside of this state.

FightScreen

Now, when you need to transit to a battle switch the ActiveScreen but don't dispose of the underlying screen. Your StateManager should have a mechanism for disabling sending input to screens that are not active and not drawing them (optional; maybe you can enable drawing if you need overlay screens). However, the point is your state is preserved.

See this stack:

enter image description here

Now, when the fight is over you would simply pop the FightScreen off the stack and your GameplayScreen would automatically resume!

If you have any other questions, comment and I advise you also check out the RPG Sample for more tips and a working sample that deploys this strategy.

\$\endgroup\$
  • 1
    \$\begingroup\$ That is exactly what was looking for. Obviously, I am new to the XNA flow. I am used to the WP flow which involves page navigation. It totally makes sense to just draw a different screen but stay on the same 'page.' Thanks! \$\endgroup\$ – hurricaneMitch Mar 7 '13 at 3:10
  • \$\begingroup\$ No problem; don't be afraid to ask questions after using the search function. \$\endgroup\$ – Vaughan Hilts Mar 7 '13 at 3:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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