Beispiel #1
0
        public override void Draw(GameTime gameTime)
        {
            sampleFrames++;

            SpriteBatch spriteBatch = debugManager.SpriteBatch;
            SpriteFont font = debugManager.DebugFont;

            // Compute size of border area.
            Vector2 size = font.MeasureString("X");
            Rectangle rc =
                new Rectangle(0, 0, (int)(size.X * 14f), (int)(size.Y * 1.3f));

            Layout layout = new Layout(spriteBatch.GraphicsDevice.Viewport);
            rc = layout.Place(rc, 0.01f, 0.01f, Alignment.TopLeft);

            // Place FPS string in border area.
            size = font.MeasureString(stringBuilder);
            layout.ClientArea = rc;
            Vector2 pos = layout.Place(size, 0, 0.1f, Alignment.Center);

            // Draw
            spriteBatch.Begin();
            spriteBatch.Draw(debugManager.WhiteTexture, rc, new Color(0, 0, 0, 128));
            spriteBatch.DrawString(font, stringBuilder, pos, Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }
Beispiel #2
0
        public void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = SpriteBatchManager.Instance.getSpriteBatchDebugHud();

            // Show usage.
            string message =
                "ScreenCursorCoords X:" + Math.Round(mouseScreenPosition.X) + ", Y:" + Math.Round(mouseScreenPosition.Y) + "\n" +
                "WorldCursorCoords X:" + Math.Round(mouseWorldPosition.X) + ", Y:" + Math.Round(mouseWorldPosition.Y);

            Vector2 size = font.MeasureString(message);
            Layout layout = new Layout(game.GraphicsDevice.Viewport);

            float margin = font.LineSpacing;
            Rectangle rc = new Rectangle(0, 0,
                                    (int)(size.X + margin),
                                    (int)(size.Y + margin));

            // Compute boarder size, position.
            rc = layout.Place(rc, 0.01f, 0.01f, Alignment.TopRight);
            spriteBatch.Draw(blank, rc, Color.Black * .5f);

            spriteBatch.Draw(pointer, mouseScreenPosition, new Rectangle(0, 0, pointer.Width, pointer.Height),
                Color.White * 0.7f, 0, new Vector2(pointer.Width / 2, pointer.Height / 2), 1, SpriteEffects.None, 1);

            // Draw usage message text.
            layout.ClientArea = rc;
            Vector2 pos = layout.Place(size, 0, 0, Alignment.Center);
            spriteBatch.DrawString(font, message, pos, Color.White);

            game.CollisionManager.Draw(gameTime);
            game.GameConsole.Draw(gameTime);
        }
Beispiel #3
0
        protected override void LoadContent()
        {
            Width = (int)(GraphicsDevice.Viewport.Width * 0.8f);

            Layout layout = new Layout(GraphicsDevice.Viewport);
            position = layout.Place(new Vector2(Width, BarHeight),
                                                    0, 0.01f, Alignment.BottomCenter);

            base.LoadContent();
        }