예제 #1
0
        public override void Start()
        {
            base.Start();

            var font = Asset.Load<SpriteFont>("Font");
            var textBlock = new TextBlock { TextColor = Color.White, Font = font, Text = UIText };
            textBlock.SetCanvasPinOrigin(new Vector3(1, 0, 0));
            textBlock.SetCanvasRelativePosition(new Vector3(0.63f, 0.8f, 0f));

            Entity.Get<UIComponent>().RootElement = new Canvas { Children = { textBlock } };
        }
예제 #2
0
        // Create the UI layout and content
        public void Start()
        {
            textBlock = new TextBlock
            {
                Text = "Tap The Screen!",
                Font = Asset.Load<SpriteFont>("Font"),
                TextAlignment = TextAlignment.Center,
            };
            textBlock.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 0f));
            textBlock.SetCanvasRelativePosition(new Vector3(0.5f, 0.85f, 0f));

            Entity.Get<UIComponent>().RootElement = new Canvas { Children = { textBlock } };
        }
예제 #3
0
        public override void Start()
        {
            base.Start();

            var textBlock = new TextBlock
            {
                Text = "Shoot the cubes!",
                Font = Asset.Load<SpriteFont>("Font"),
                TextColor = Color.White,
                TextSize = 60
            };
            textBlock.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 0));
            textBlock.SetCanvasRelativePosition(new Vector3(0.5f, 0.9f, 0f));

            Entity.Get<UIComponent>().RootElement = new Canvas { Children = { textBlock } };
        }
예제 #4
0
        public override void Start()
        {
            simulation = Entity.Get<PhysicsComponent>().Simulation;
            simulation.Gravity = new Vector3(0, -9, 0);

            cubeRigidBody = cube.Get<PhysicsComponent>()[0].RigidBody;
            cubeRigidBody.CanSleep = false;
            sphereRigidBody = sphere.Get<PhysicsComponent>()[0].RigidBody;
            sphereRigidBody.CanSleep = false;

            // Create the UI
            var font = Asset.Load<SpriteFont>("Font");
            constraintNameBlock = new TextBlock
            {
                Font = font,
                TextSize = 55,
                TextColor = Color.White,
            };
            constraintNameBlock.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 0));
            constraintNameBlock.SetCanvasRelativePosition(new Vector3(0.5f, 0.93f, 0));

            Entity.Get<UIComponent>().RootElement = new Canvas
            {
                Children =
                {
                    constraintNameBlock,
                    CreateButton("Next Constraint", font, 1),
                    CreateButton("Last Constraint", font, -1)
                }
            };

            // Create and initialize constraint
            constraintsList.Add(CreatePoint2PointConstraint);
            constraintsList.Add(CreateHingeConstraint);
            constraintsList.Add(CreateGearConstraint);
            constraintsList.Add(CreateSliderConstraint);
            constraintsList.Add(CreateConeTwistConstraint);
            constraintsList.Add(CreateGeneric6DoFConstraint);

            constraintsList[constraintIndex]();
        }
예제 #5
0
        public override async Task Execute()
        {
            var textBlock = new TextBlock
            {
                Text = "Use arrows to play with gravity!", 
                Font = Asset.Load<SpriteFont>("SpriteFont"), 
                TextColor = Color.White, 
                TextSize = 40
            };
            textBlock.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 0));
            textBlock.SetCanvasRelativePosition(new Vector3(0.5f, 0.75f, 0f));
            Entity.Get<UIComponent>().RootElement = new Canvas { Children = { textBlock } };

            while (Game.IsRunning)
            {
                await Script.NextFrame();

                if (!Input.IsKeyPressed(Keys.Left) && !Input.IsKeyPressed(Keys.Right) && !Input.IsKeyPressed(Keys.Up) &&
                    !Input.IsKeyPressed(Keys.Down)) continue;

                Entity.Get<UIComponent>().RootElement = null;
                return;
            }
        }
예제 #6
0
        private void CreateGameUI()
        {
            distanceTextBlock = new TextBlock { Font = spriteFont, TextColor = Color.Gold, VerticalAlignment = VerticalAlignment.Center };
            distanceTextBlock.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 1f));
            distanceTextBlock.SetCanvasRelativePosition(new Vector3(0.2f, 0.05f, 0f));

            var scoreBoard = new ContentDecorator
            {
                BackgroundImage = uiImages["distance_bg"],
                Content = distanceTextBlock,
                Padding = new Thickness(60, 31, 25, 35),
                MinimumWidth = 290f // Set the minimum width of score button so that it wont modify when the content (text) changes, and less than minimum.
            };

            gameRoot = new Canvas();
            gameRoot.Children.Add(scoreBoard);
        }