Пример #1
0
        public CCPhysicsShapeEdgePolygon(CCPoint[] vec, int count, CCPhysicsMaterial material, float border = 1)
        {
            _type = PhysicsType.EDGEPOLYGEN;

            int i    = 0;
            var vecs = PhysicsHelper.CCPointsTocpVects(vec);

            for (; i < count; ++i)
            {
                cpShape shape = new cpSegmentShape(CCPhysicsShapeInfo.SharedBody, vecs[i], vecs[(i + 1) % count],
                                                   border);

                if (shape == null)
                {
                    break;
                }

                shape.SetElasticity(1.0f);
                shape.SetFriction(1.0f);

                _info.Add(shape);
            }

            _mass   = cp.Infinity;
            _moment = cp.Infinity;

            Material = material;
        }
Пример #2
0
        public CCPhysicsShapeEdgeChain(CCPoint[] vec, int count, CCPhysicsMaterial material, float border = 1)
        {
            _type = PhysicsType.EDGECHAIN;
            var vecs = PhysicsHelper.CCPointsTocpVects(vec);
            int i    = 0;

            for (; i < count; ++i)
            {
                cpShape shape = new cpSegmentShape(CCPhysicsShapeInfo.getSharedBody(), vecs[i], vecs[i + 1],
                                                   border);
                shape.SetElasticity(1.0f);
                shape.SetFriction(1.0f);

                _info.add(shape);
            }

            _mass   = cp.Infinity;
            _moment = cp.Infinity;

            SetMaterial(material);
        }