protected override void Draw(GameTime gameTime) { drawMarker.Begin(); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0); // ゲームオブジェクトの描画 DrawGameObjects(); // ステータス表示 float margin = font.LineSpacing * 0.2f; Vector2 size = font.MeasureString(statusString); size.Y += margin * 2.0f; var layout = new DebugLayout(); layout.ContainerBounds = GraphicsDevice.Viewport.Bounds; layout.Width = (int)size.X; layout.Height = (int)size.Y; layout.HorizontalAlignment = DebugHorizontalAlignment.Left; layout.VerticalAlignment = DebugVerticalAlignment.Top; layout.HorizontalMargin = 8; layout.VerticalMargin = 8; layout.Arrange(); spriteBatch.Begin(); spriteBatch.Draw(fillTexture, layout.ArrangedBounds, new Color(0, 0, 0, 200)); spriteBatch.DrawString( font, statusString, new Vector2(layout.ArrangedBounds.X, layout.ArrangedBounds.Y + margin), Color.White); spriteBatch.End(); drawMarker.End(); base.Draw(gameTime); }
void DrawHelp() { if (!helpVisible) { return; } spriteBatch.Begin(); var layout = new DebugLayout(); int informationWidth = 380; // calculate the background area for information. layout.ContainerBounds = GraphicsDevice.Viewport.TitleSafeArea; layout.Width = informationWidth + 4; layout.Height = (int)informationTextFontSize.Y + 2; layout.HorizontalMargin = 8; layout.VerticalMargin = 8; layout.HorizontalAlignment = DebugHorizontalAlignment.Left; layout.VerticalAlignment = DebugVerticalAlignment.Top; layout.Arrange(); // draw the rectangle. spriteBatch.Draw(fillTexture, layout.ArrangedBounds, Color.Black * 0.5f); // calculate the text area for information. layout.ContainerBounds = layout.ArrangedBounds; layout.Width = informationWidth; layout.Height = (int)informationTextFontSize.Y; layout.HorizontalMargin = 2; layout.VerticalMargin = 0; layout.HorizontalAlignment = DebugHorizontalAlignment.Center; layout.VerticalAlignment = DebugVerticalAlignment.Center; layout.Arrange(); // draw the text. BuildInfoMessage(); spriteBatch.DrawString(font, stringBuilder, new Vector2(layout.ArrangedBounds.X, layout.ArrangedBounds.Y), Color.Yellow); // calculate the background area for help messages. layout.ContainerBounds = GraphicsDevice.Viewport.TitleSafeArea; layout.Width = (int)helpMessageFontSize.X + 4; layout.Height = (int)helpMessageFontSize.Y + 2; layout.HorizontalMargin = 8; layout.VerticalMargin = 8; layout.HorizontalAlignment = DebugHorizontalAlignment.Left; layout.VerticalAlignment = DebugVerticalAlignment.Bottom; layout.Arrange(); // draw the rectangle. spriteBatch.Draw(fillTexture, layout.ArrangedBounds, Color.Black * 0.5f); // calculate the text area for help messages. layout.ContainerBounds = layout.ArrangedBounds; layout.Width = (int)helpMessageFontSize.X; layout.Height = (int)helpMessageFontSize.Y; layout.HorizontalMargin = 2; layout.VerticalMargin = 0; layout.HorizontalAlignment = DebugHorizontalAlignment.Center; layout.VerticalAlignment = DebugVerticalAlignment.Center; layout.Arrange(); // draw the text. spriteBatch.DrawString(font, helpMessage, new Vector2(layout.ArrangedBounds.X, layout.ArrangedBounds.Y), Color.Yellow); spriteBatch.End(); }