Пример #1
0
 /// <summary>
 /// Calcule et renvoie la matrice de transformation qui sera appliquée au spritebatch
 /// et qui fera en sorte de suivre le joueur
 /// </summary>
 /// <returns>Une matrice de transformation de la caméra</returns>
 public Matrix GetViewMatrix(MenuPage page)
 {
     if (page.GetType() == typeof(GamePage))
     {
         Origin = new Vector2(GamePage.player.Center.X - viewport.Width / 2f, GamePage.player.Center.Y - viewport.Height / 2f);
         return
             (Matrix.CreateTranslation(new Vector3(-Position, 0.0f)) *
              Matrix.CreateTranslation(new Vector3(-origin, 0.0f)) *
              Matrix.CreateScale(Zoom, Zoom, 1));
     }
     return
         (Matrix.CreateTranslation(new Vector3(-Position, 0.0f)) *
          Matrix.CreateScale(Zoom, Zoom, 1));
 }