Reputation: 23
I'm making a text based game on Xamarin.Forms. currently my main page has a "Start Game" Button. and I'm using NavigationPage to go to the game page, like so:
Navigation.PushAsync(new GamePage());
I'm Trying to add a "Resume Game" Button that will go the game page but with all the data that exists in it. basically i want it so that when you exit the "Game Page" the data doesn't wipe. and you can resume it at anytime. I'm wondering if this at all possible as the data on the Game Page is to much to just call it all when invoking the page.
Upvotes: 1
Views: 311
Reputation: 51
There is no way to load an existing page directly into Xamarin. You will need to think about another way to store the game state.
The easiest way is to use a text file (xml, json...) that you will load and pass as parameter to your page.
Don't forget to save the state in the different events of the App Life Cycle to avoid data loss.
Upvotes: 0
Reputation: 1611
You can define game data on GamePage's constructor. And you can easily pass your data to this GamePage via constructor. For Example :
Navigation.PushAsync(new GamePage(gameData));
and your data does not wipe.
Upvotes: 1