protected override void Initialize()
        {
            this.graphicsDevice.CreateDevice();

            this.graphics = new GraphicsBatch(this.graphicsDevice);

            this.font = this.contentLoader.Load<TextureFont>(new LoadTextureFontArgs()
            {
                FileName = "TextBlockFont.xml"
            });

            Size textBlockSize = new Size(this.graphicsDevice.BackBufferWidth / 3, this.graphicsDevice.BackBufferHeight / 3);

            this.topLeftTextBlock = new TextBlock(this.font, "Top\nLeft\nText\nBlock", textBlockSize, TextAlignment.TopLeft);
            this.topCenterTextBlock = new TextBlock(this.font, "Top\nCenter\nText\nBlock", textBlockSize, TextAlignment.TopCenter);
            this.topRightTextBlock = new TextBlock(this.font, "Top\nRight\nText\nBlock", textBlockSize, TextAlignment.TopRight);

            this.middleLeftTextBlock = new TextBlock(this.font, "Middle\nLeft\nText\nBlock", textBlockSize, TextAlignment.MiddleLeft);
            this.middleCenterTextBlock = new TextBlock(this.font, "Middle\nCenter\nText\nBlock", textBlockSize, TextAlignment.MiddleCenter);
            this.middleRightTextBlock = new TextBlock(this.font, "Middle\nRight\nText\nBlock", textBlockSize, TextAlignment.MiddleRight);

            this.bottomLeftTextBlock = new TextBlock(this.font, "Bottom\nLeft\nText\nBlock", textBlockSize, TextAlignment.BottomLeft);
            this.bottomCenterTextBlock = new TextBlock(this.font, "Bottom\nCenter\nText\nBlock", textBlockSize, TextAlignment.BottomCenter);
            this.bottomRightTextBlock = new TextBlock(this.font, "Bottom\nRight\nText\nBlock", textBlockSize, TextAlignment.BottomRight);
        }
Exemple #2
0
        protected override void Initialize()
        {
            this.graphicsDevice.CreateDevice(800, 600, false);

            this.soundDevice.CreateDevice();

            this.console.Initialize();
            this.console.BackgroundTexture = this.contentManager.Load<Texture>(DemoGameContent.ConsoleBackground);

            this.ship.LoadContent(this.contentManager);

            this.graphics = new GraphicsBatch(this.graphicsDevice);

            this.font = this.contentManager.Load<TextureFont>(DemoGameContent.Font);
            this.textBlock = new TextBlock(this.font, "This is text\nspanning multiple lines.", new Size(800, 600), TextAlignment.MiddleCenter, Vector2.One);

            this.starfield.Initialize();
            this.ship.Initialize();
        }
        public void DrawTextBlock(TextBlock textBlock, Vector2 position, Color color)
        {
            if (textBlock == null)
                throw new ArgumentNullException("textBlock");

            for (int i = 0; i < textBlock.Length; i++)
            {
                TextBlock.Character character = textBlock[i];

                Rectangle destination = character.Destination;
                destination.X += (int)position.X;
                destination.Y += (int)position.Y;

                this.DrawTexture(textBlock.Font.Texture, destination, character.Source, color);
            }
        }