SamplyGame.Background.Start C# (CSharp) Method

Start() public method

public Start ( ) : void
return void
		public void Start()
		{
			// Background consists of two huge tiles (each BackgroundScale x BackgroundScale)
			frontTile = CreateTile(0);
			rearTile = CreateTile(1);

			// Move them and swap (rotate) to be looked like the background is infinite
			RotateBackground();
		}

Usage Example

コード例 #1
0
        private async void CreateScene()
        {
            scene = new Scene();
            scene.CreateComponent <Octree>();
            var physics = scene.CreateComponent <PhysicsWorld>();

            physics.SetGravity(new Vector3(0, 0, 0));
            // Camera
            var cameraNode = scene.CreateChild();

            cameraNode.Position = (new Vector3(0.0f, 0.0f, -10.0f));
            cameraNode.CreateComponent <Camera>();
            Viewport = new Viewport(Context, scene, cameraNode.GetComponent <Camera>(), null);
            if (Platform != Platforms.Android && Platform != Platforms.iOS)
            {
                RenderPath effectRenderPath = Viewport.RenderPath.Clone();
                var        fxaaRp           = ResourceCache.GetXmlFile(Assets.PostProcess.FXAA3);
                effectRenderPath.Append(fxaaRp);
                Viewport.RenderPath = effectRenderPath;
            }
            Renderer.SetViewport(0, Viewport);
            var zoneNode = scene.CreateChild();
            var zone     = zoneNode.CreateComponent <Zone>();

            zone.SetBoundingBox(new BoundingBox(-300.0f, 300.0f));
            zone.AmbientColor = new Color(1f, 1f, 1f);
            // UI
            coinsText = new Text();
            coinsText.HorizontalAlignment = HorizontalAlignment.Right;
            coinsText.SetFont(ResourceCache.GetFont(Assets.Fonts.Font), Graphics.Width / 20);
            UI.Root.AddChild(coinsText);
            Input.SetMouseVisible(true, false);
            // Background
            var background = new Background();

            scene.AddComponent(background);
            background.Start();
            // Luci
            var lightNode = scene.CreateChild();

            lightNode.Position = new Vector3(0, -5, -40);
            lightNode.AddComponent(new Light {
                Range = 120, Brightness = 0.8f
            });
            // ciclo della logica di gioco
            bool firstCycle = true;

            while (true)
            {
                var startMenu = scene.CreateComponent <StartMenu>();
                await startMenu.ShowStartMenu(!firstCycle); //wait for "start"

                startMenu.Remove();
                await StartGame();

                firstCycle = false;
            }
        }
All Usage Examples Of SamplyGame.Background::Start