Пример #1
0
        //protected cpVect _offset;
        #endregion

        #region PUBLIC METHODS

        public CCPhysicsShapeBox(CCSize size, CCPhysicsMaterial material, float radius)
        {
            cpVect wh = PhysicsHelper.size2cpv(size);

            _type = PhysicsType.BOX;

            cpVect[] vec =
            {
                new cpVect(-wh.x / 2.0f, -wh.y / 2.0f),
                new cpVect(-wh.x / 2.0f, wh.y / 2.0f),
                new cpVect(wh.x / 2.0f,  wh.y / 2.0f),
                new cpVect(wh.x / 2.0f, -wh.y / 2.0f)
            };

            cpShape shape = new cpPolyShape(CCPhysicsShapeInfo.SharedBody, 4, vec, radius);

            _info.Add(shape);

            //_offset = offset;
            _area   = CalculateArea();
            _mass   = material.density == cp.Infinity ? cp.Infinity : material.density * _area;
            _moment = CalculateDefaultMoment();

            Material = material;
        }