Пример #1
0
        public Scoreboard(Sprite2D Red, Sprite2D Blue, Vector2 ScreenScaleFactor)
        {
            this.RedPlayerImage = Red;
            this.BluePlayerImage = Blue;
            RedCount = TextBox.CreateTextBox(Red.Left+Red.Width+10, 30, ScreenScaleFactor, null, 0.6f, 0, 0, true);
            RedCount.InitTextBox();
            RedCount.SetFont("ScoreFont");
            RedCount.SetColor(Color.WhiteSmoke);

            BlueCount = TextBox.CreateTextBox(Blue.Left+Blue.Width+10, 110, ScreenScaleFactor, null, 0.6f, 0, 0, true);
            BlueCount.InitTextBox();
            BlueCount.SetFont("ScoreFont");
            BlueCount.SetColor(Color.WhiteSmoke);

            Result = TextBox.CreateTextBox(-50, 190, ScreenScaleFactor, null, 0.6f, 0, 0, true);
            Result.InitTextBox();
            Result.SetFont("WinFont");
            Result.SetColor(Color.WhiteSmoke);

            Notify = TextBox.CreateTextBox(-70, -60, ScreenScaleFactor, null, 0.6f, 0, 0, true);
            Notify.InitTextBox();
            Notify.SetFont("WinFont");
            Notify.SetColor(blue);

            AddChild(Red);
            AddChild(Blue);
            AddChild(RedCount);
            AddChild(BlueCount);
            AddChild(Result);
            AddChild(Notify);
        }
Пример #2
0
        public static TextBox CreateTextBox(float left, float top, Vector2 ScreenScaleFactor, String path, float depth = 1.0f, int width = 0, int height = 0, bool isLabel = false)
        {
            List<Texture2D> textures = new List<Texture2D>();
            if (path != null)
            {
                Texture2D newTexture = Global.thisGame.Content.Load<Texture2D>(path);
                textures.Add(newTexture);

                if (width == 0)
                    width = newTexture.Width;

                if (height == 0)
                    height = newTexture.Height;

                width = (int)((float)width * ScreenScaleFactor.X);
                height = (int)((float)height * ScreenScaleFactor.Y);
            }

            top = top * ScreenScaleFactor.Y;
            left = left * ScreenScaleFactor.X;

            TextBox temp = new TextBox(textures, left, top, width, height, true);
            temp.isLabel = isLabel;
            if (!isLabel)
                Global.textBoxes.Add(temp);
            temp._Depth = depth;
            return temp;
        }