예제 #1
0
        private void CreateMainMenuUI()
        {
            var strideLogo = new ImageElement {
                Source = SpriteFromSheet.Create(UIImages, "sd_logo")
            };

            strideLogo.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 1f));
            strideLogo.SetCanvasRelativeSize(new Vector3(0.75f, 0.5f, 1f));
            strideLogo.SetCanvasRelativePosition(new Vector3(0.5f, 0.3f, 1f));

            var startButton = new Button
            {
                Content = new TextBlock
                {
                    Font                = Font,
                    Text                = "Touch to Start",
                    TextColor           = Color.Black,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center
                },
                NotPressedImage = buttonImage,
                PressedImage    = buttonImage,
                MouseOverImage  = buttonImage,
                Padding         = new Thickness(77, 30, 25, 30),
                MinimumWidth    = 250f,
            };

            startButton.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 1f));
            startButton.SetCanvasRelativePosition(new Vector3(0.5f, 0.7f, 0f));
            startButton.Click += (sender, args) =>
            {
                GameGlobals.GameStartedEventKey.Broadcast();
                StartGameMode();
            };

            var mainMenuCanvas = new Canvas();

            mainMenuCanvas.Children.Add(strideLogo);
            mainMenuCanvas.Children.Add(startButton);

            mainMenuRoot = new ModalElement
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Content             = mainMenuCanvas
            };
        }
예제 #2
0
파일: UIScript.cs 프로젝트: ogi-mochi/xenko
        private void CreateMainMenuUI()
        {
            var xenkoLogo = new ImageElement {
                Source = SpriteFromSheet.Create(UIImages, "xk_logo")
            };

            xenkoLogo.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 1f));
            xenkoLogo.SetCanvasRelativeSize(new Vector3(0.75f, 0.5f, 1f));
            xenkoLogo.SetCanvasRelativePosition(new Vector3(0.5f, 0.3f, 1f));

            StartButton = new Button
            {
                Content = new TextBlock {
                    Font = Font, Text = "Touch to Start", TextColor = Color.Black,
                    HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center
                },
                NotPressedImage = buttonImage,
                PressedImage    = buttonImage,
                MouseOverImage  = buttonImage,
                Padding         = new Thickness(77, 30, 25, 30),
                MinimumWidth    = 250f,
            };

            StartButton.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 1f));
            StartButton.SetCanvasRelativePosition(new Vector3(0.5f, 0.7f, 0f));

            var mainMenuCanvas = new Canvas();

            mainMenuCanvas.Children.Add(xenkoLogo);
            mainMenuCanvas.Children.Add(StartButton);

            mainMenuRoot = new ModalElement
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Content             = mainMenuCanvas
            };
        }