示例#1
0
 /// <summary>
 /// Add a layer to a level.
 /// </summary>
 /// <param name="level">The level to add the layer to.</param>
 /// <param name="name">The name of the layer.</param>
 /// <param name="scrollSpeed">The scrolling speed of this layer. Used for parallex scrolling.</param>
 public Layer AddLayer(Level level, string name, Vector2 scrollSpeed)
 {
     //Add the layer and return it.
     return level.AddLayer(name, scrollSpeed);
 }
示例#2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Initialize camera controls
            _screenCenter = new Vector2(_graphics.GraphicsDevice.Viewport.Width / 2, _graphics.GraphicsDevice.Viewport.Height / 2);
            _Camera = new Camera2D(Window.ClientBounds, new Rectangle(0, 0, 2000, 2000));
            _Camera.Position = _screenCenter;

            _batch = new SpriteBatch(_graphics.GraphicsDevice);
            _font = Content.Load<SpriteFont>(@"GameScreen/Fonts/diagnosticFont");
            _World = new World(new Vector2(0, 20));

            _Level = new Level("Level 1", _Camera);
            _Level.LoadContent(_graphics.GraphicsDevice, Content);
            Layer layer = _Level.AddLayer("Layer 1", Vector2.One);

            Box box1 = Factory.Instance.AddBox(layer, "Ground", @"General/Textures/FrozenMetalGroundV1[1]", new Vector2(800, 700), 937, 32);
            box1.Limbs[0].Body.BodyType = FarseerPhysics.Dynamics.BodyType.Static;

            Body ground = BodyFactory.CreateRectangle(_World, 937 / MeterInPixels, 32 / MeterInPixels, 1);
            ground.BodyType = BodyType.Static;
            ground.Position = new Vector2(800, 700) / MeterInPixels;
            ground.Friction = .5f;

            for (int i = 0; i <= 5; i++)
            {
                Box box2 = Factory.Instance.AddBox(layer, "Box", @"General/Textures/BlueBoxV1[1]", new Vector2(500 + 50 * i, 50), 26, 27);
                box2.Limbs[0].Body.Restitution = .1f * i;
                box2.Limbs[0].Body.Mass = 1 + 10 * i;
            }

            box = BodyFactory.CreateRectangle(_World, 26 / MeterInPixels, 27 / MeterInPixels, 1);
            box.BodyType = BodyType.Dynamic;
            box.Restitution = .5f;
            //box.Mass = 51;
            box.Position = new Vector2(900, 50) / MeterInPixels;
            box.Position = (_screenCenter / MeterInPixels);

            _debugViewLevel = new DebugViewXNA(_Level.World);
            _debugViewLevel.Enabled = true;
            _debugViewLevel.LoadContent(_graphics.GraphicsDevice, Content);

            _debugView = new DebugViewXNA(_World);
            _debugView.Enabled = true;
            _debugView.LoadContent(_graphics.GraphicsDevice, Content);
        }
示例#3
0
 /// <summary>
 /// Add a layer to a level.
 /// </summary>
 /// <param name="level">The level to add the layer to.</param>
 /// <param name="layer">The level to add.</param>
 public Layer AddLayer(Level level, Layer layer)
 {
     //Add the layer and return it.
     return level.AddLayer(layer);
 }