Esempio n. 1
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _bitmapFont = Content.Load<BitmapFont>("montserrat-32");

            var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480);
            _camera = new Camera2D(viewportAdapter)
            {
                Zoom = 2.0f
            };
            _sceneGraph = new SceneGraph();

            var carHullTexture = Content.Load<Texture2D>("car-hull");
            var carHullSprite = new Sprite(carHullTexture);
            var carWheelTexture = Content.Load<Texture2D>("car-wheel");
            var carWheelSprite = new Sprite(carWheelTexture);

            _carNode = new SceneNode("car-hull", viewportAdapter.Center.ToVector2());
            _carNode.Entities.Add(carHullSprite);

            _leftWheelNode = new SceneNode("left-wheel", new Vector2(-29, 17));
            _leftWheelNode.Entities.Add(carWheelSprite);

            _rightWheelNode = new SceneNode("right-wheel", new Vector2(40, 17));
            _rightWheelNode.Entities.Add(carWheelSprite);

            _carNode.Children.Add(_rightWheelNode);
            _carNode.Children.Add(_leftWheelNode);
            _sceneGraph.RootNode.Children.Add(_carNode);
        }
 public static void Draw(this SpriteBatch spriteBatch, SceneGraph sceneGraph)
 {
     sceneGraph.Draw(spriteBatch);
 }