Beispiel #1
0
        protected override void Open()
        {
            Scene.IsPaused = true;
            List <Body> bodies = new List <Body>();

            Body b = DemoHelper.AddLine(DemoInfo, new Vector2D(300, 200), new Vector2D(400, 200), 40, Scalar.PositiveInfinity);

            b.IgnoresPhysicsLogics = true;
            bodies.Add(b);
            Body b2 = DemoHelper.AddCircle(DemoInfo, 20, 40, Scalar.PositiveInfinity, new ALVector2D(0, 300, 100));

            b2.IgnoresPhysicsLogics = true;
            bodies.Add(b2);
            Body b3 = DemoHelper.AddCircle(DemoInfo, 20, 40, 50, new ALVector2D(0, 100, 100));

            bodies.Add(b3);
            Body b4 = DemoHelper.AddRectangle(DemoInfo, 20, 20, 20, new ALVector2D(0, 150, 150));

            bodies.Add(b4);

            dispose += RegisterDup(DemoInfo, bodies);

            DemoHelper.AddShell(DemoInfo, new BoundingRectangle(0, 0, 200, 200), 10, Scalar.PositiveInfinity).ForEach(delegate(Body sb) { sb.IgnoresPhysicsLogics = true; });



            Body bStart = DemoHelper.AddShape(DemoInfo, ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("start.png"), 2, 16, 3), Scalar.PositiveInfinity, new ALVector2D(0, 100, 650));

            // Body bStart = DemoHelper.AddLine(DemoInfo, new Vector2D(10, 600), new Vector2D(100, 600), 40, Scalar.PositiveInfinity);
            bStart.IgnoresPhysicsLogics = true;
            Body bStop = DemoHelper.AddShape(DemoInfo, ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("stop.png"), 2, 16, 3), Scalar.PositiveInfinity, new ALVector2D(0, 100, 700));

            //Body bEnd = DemoHelper.AddLine(DemoInfo, new Vector2D(10, 700), new Vector2D(100, 700), 40, Scalar.PositiveInfinity);
            bStop.IgnoresPhysicsLogics = true;

            Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan()));

            dispose += DemoHelper.RegisterClick(DemoInfo, bStart, MouseButton.PrimaryButton,
                                                delegate(object sender, EventArgs e)
            {
                Scene.IsPaused = false;
            });
            dispose += DemoHelper.RegisterClick(DemoInfo, bStop, MouseButton.PrimaryButton,
                                                delegate(object sender, EventArgs e)
            {
                Scene.IsPaused = true;
            });
        }