示例#1
0
        public void CreateMenu(Game1 game)
        {
            _desktop = new Desktop(game.Batch);

            var root = _desktop.Root;

            var label = _factory.CreateLabel(1);

            label.OffsetFrom = Anchors.TopCenter;
            label.Offset     = new Vector2(0, 40);
            label.Text       = "My cool game";
            label.ComputeSize(Vector2.Zero, Autosize.Content);

            var content = new ContentControll();

            content.OffsetFrom = Anchors.Center;

            var start = _factory.CreateTextButton(0);

            start.OffsetFrom = Anchors.Center;
            start.Offset     = new Vector2(0, -80);
            start.Text       = "New game";
            start.MouseUp   += (s, e) =>
            {
                LoadGame();
            };

            var options = _factory.CreateTextButton(0);

            options.OffsetFrom = Anchors.Center;
            options.Text       = "Options";

            var exit = _factory.CreateTextButton(0);

            exit.OffsetFrom = Anchors.Center;
            exit.Offset     = new Vector2(0, 80);
            exit.Text       = "Exit";

            var border = _factory.CreatePanel(3);

            border.Border = new Margin(40, 40);
            border.ComputeSize(_desktop.Size - new Vector2(25), Autosize.Fill);
            border.OffsetFrom = Anchors.Center;
            border.StretchTexture();

            var panel = _factory.CreatePanel(4);

            panel.ComputeSize(_desktop.Size, Autosize.Content);

            content.Children.Add(panel);
            content.Children.Add(start);
            content.Children.Add(options);
            content.Children.Add(exit);

            content.ComputeSize(root.Size, Autosize.Content);

            root.Children.Add(border);
            root.Children.Add(label);
            root.Children.Add(content);
        }
示例#2
0
        public LoadingScreen(Game1 game, Action action) : base(game)
        {
            _factory = game.Services.GetService <ControlsFactory>();
            _desktop = new Desktop(game.Batch);
            var label = _factory.CreateLabel(fontName: "fonts/commodore64");

            label.OffsetFrom = Anchors.Center;
            label.Text       = "Loading...";
            label.ComputeSize(Vector2.Zero, Autosize.Content);
            _desktop.Root.Children.Add(label);
            afterAction = action;
        }