title: Calling a function from another class - XNA 4.0 - C#
body: <p>Basically I am trying to implement a save function into my game. When you click save in the menu, the game writes to a .txt file. From the MenuManager class I want to call a function within Game1.cs</p>
  
  <p>This is the code in my MenuManager.cs</p>
  
  <pre><code>                case Menu.ButtonEvents.Save:
                      activeMenu.ButtonEvent = Menu.ButtonEvents.None;
                      game1.Save();
                      Show("Save Menu");
  </code></pre>
  
  <p>The third line is where I want to call the function in Game1.cs</p>
  
  <p>In Game1.cs I have the save function </p>
  
  <pre><code>    public void Save()
      {
          // Example #1: Write an array of strings to a file. 
          // Create a string array that consists of three lines. 
          string[] lines = { levelIndex.ToString(), player.checkpointPos.X.ToString(), player.checkpointPos.Y.ToString() };
          System.IO.File.WriteAllLines("WriteText.txt", lines);
      }
  </code></pre>
  
  <p>The problem for me is that I have all of the variables in Game1.cs, but the Save Button is pressed within the MenuManager system. Any help would be greatly appreciated.</p>