示例#1
0
        protected override void Resize(GameHost.WindowStates windowState, Vector2 newSize, Vector2 oldSize)
        {
            base.Resize(windowState, newSize, oldSize);

            // Calculate the screen aspect ratio
            float aspectRatio = newSize.X / newSize.Y;
            // Create a projection matrix
            Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), aspectRatio, 0.1f, 1000.0f);

            // Set the projection matrix into the effect
            _effect.Projection = projection;

            // Update the text object to show the new window size
            SetWindowSizeText();
            // Update text object positions to match the new window size
            AutoUpdateTextPositions(newSize.X, oldSize.X);
        }
 /// <summary>
 /// Virtual method which the game may override if it needs to respond to the game window resizing
 /// </summary>
 /// <param name="windowState">The new window state</param>
 /// <param name="newSize">A Vector2 structure containing the new window size</param>
 /// <param name="oldSize">A Vector2 structure containing the previous window size</param>
 protected internal virtual void Resize(GameHost.WindowStates windowState, Vector2 newSize, Vector2 oldSize)
 {
     // Nothing to do by default
 }