I am using Monogame Implementation of xna to develop a simple Air Hockey game in windows store, and I am navigating to some XAML page if any of the players attains a score of 7
this is the Logic I am using in Update method
protected override void Update(GameTime gameTime)
{
DrawGame();
if (player1.Score == 7)
{
try
{
PlayerOneScore = player1.Score;
PlayerTwoScore = player2.Score;
App.WinningFlag = true;
App.WinningPlayer = PlayerOneName;
this.Exit();
if (BaseCount == 0)
{
//Navigation to next page
BaseCount++;
Frame ff = new Frame();
ff.Navigate(typeof(NextPage));
Windows.UI.Xaml.Window.Current.Content = ff;
Windows.UI.Xaml.Window.Current.Activate();
}
}
catch (Exception)
{
throw;
}
}
base.Update(gameTime);
}
However I see that the methods Update and Draw are still getting called, Why so? Though I have written the code to navigate away from this page, Also in NextPage there is a button coded for restarting the game
Click event for button restart game in NextPage
private void btnStartNewGame_Click(object sender, RoutedEventArgs e)
{
var app = App.Current as App;
if (app.GamePage != null)
{ app.GamePage = null; app.GamePage = new GamePage(string.Empty); }
else { app.GamePage = new GamePage(string.Empty); }
Window.Current.Content = app.GamePage;
}
This renders me with a Black screen, No textures in game1.cs classes are drawn.
How can I navigate from a Game1.cs to Xaml and get Back to Game1.cs as a fresh call?