title: How to use a public bool from one class in another class? c#
body: <p>I'm trying to use a bool from class Level in class Health but I can't get it to work. I know it's probably really trivial but right now I'm stuck..</p>
  
  <p>Here's the method Uphealth from class Level:</p>
  
  <pre><code>public bool UpHealth()
  {
      SpriteGameObject healthpack = this.Find("uphealth") as SpriteGameObject;
      Player player = this.Find("player") as Player;
      if (healthpack.CollidesWith(player))
          return true;
      return false;
  }
  </code></pre>
  
  <p>Here's the method in class Health where I want to use the bool Uphealth:</p>
  
  <pre><code>public override void Update(GameTime gameTime)
  {
      base.Update(gameTime);
      Player player = GameWorld.Find("player") as Player;
      AnimatedGameObject rocket = GameWorld.Find("rocket") as AnimatedGameObject;
  
      foreach (GameObject obj in gameObjects)
      {
          SpriteGameObject h = obj as SpriteGameObject;
          if ( &lt;---I DON'T KNOW WHAT TO TYPE HERE---&gt; )
          {
              this.Add(h);
              return;
          }
      }
  }
  </code></pre>
  
  <p>I want it to be when Uphealth is true it performs the this.Add(h);</p>
  
  <p>What do I need to do to be able to use Uphealth in the class Health?</p>