Esempio 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);
            }
        }
Esempio n. 2
0
        public RobDemo(Image image)
            : base(image)
        {
            Settings.ContactIteration = 20;

            _combinedParticle = new CombinedParticle(_vertexs, 3, 1, true);
            PhysicsWorld.AddObject(_combinedParticle);

            // 为顶点绑定形状
            foreach (var vertex in _combinedParticle.Vertexs)
            {
                vertex.BindShape(new Circle(4.ToSimUnits()));
            }

            // 增加边缘
            PhysicsWorld.CreatePolygonEdge(_edgePoints.ToArray());

            // 增加重力
            PhysicsWorld.CreateGravity(9.8);

            DrawQueue.Add(this);
            Start = true;
        }