Exemplo n.º 1
0
        public void Fire(double x, double y)
        {
            if (!Start)
            {
                Start = true;
                // 增加重力
                PhysicsWorld.CreateGravity(9.8);
                // 添加边缘
                _edge = PhysicsWorld.CreateEdge(
                    100.ToSimUnits(),
                    350.ToSimUnits(),
                    400.ToSimUnits(),
                    200.ToSimUnits());
                Slot = 1 / 60.0;
            }

            var rnd = new Random();

            for (int i = 0; i < 10; i++)
            {
                var paritcle = PhysicsWorld.CreateParticle
                               (
                    new Vector2D(x, y),
                    new Vector2D(rnd.NextDouble() * 6 - 3, rnd.NextDouble() * 6 - 3),
                    1f, 0.1
                               );
                paritcle.BindShape(new Circle(BallSize.ToSimUnits(), _shapeId));
                _objList.Add(paritcle);
            }
        }