Пример #1
0
        public CCPhysicsWorld(CCScene scene)
        {
            _gravity         = new CCPoint(0.0f, -98.0f);
            _speed           = 1.0f;
            _updateRate      = 1;
            _updateRateCount = 0;
            _updateTime      = 0.0f;
            _info            = null;
            _scene           = null;
            _delayDirty      = false;

            _info = new CCPhysicsWorldInfo();

            _scene = scene;

            _info.SetGravity(PhysicsHelper.CCPointToCpVect(_gravity));

            var spc = _info.getSpace();

            spc.defaultHandler = new cpCollisionHandler()
            {
                beginFunc     = (a, s, o) => CCPhysicsWorldCallback.CollisionBeginCallbackFunc(a as cpArbiter, s, this),
                preSolveFunc  = (a, s, o) => CCPhysicsWorldCallback.CollisionPreSolveCallbackFunc(a as cpArbiter, s, this),
                postSolveFunc = (a, s, o) => CCPhysicsWorldCallback.CollisionPostSolveCallbackFunc(a as cpArbiter, s, this),
                separateFunc  = (a, s, o) => CCPhysicsWorldCallback.CollisionSeparateCallbackFunc(a as cpArbiter, s, this)
            };
        }
Пример #2
0
        public CCPhysicsWorld(CCScene scene)
        {
            DelayAddBodies    = new List <CCPhysicsBody>();
            DelayRemoveBodies = new List <CCPhysicsBody>();
            DelayAddJoints    = new List <CCPhysicsJoint>();
            DelayRemoveJoints = new List <CCPhysicsJoint>();

            Bodies = new List <CCPhysicsBody>();
            Joints = new List <CCPhysicsJoint>();

            _gravity         = new CCPoint(0.0f, -98.0f);
            _speed           = 1.0f;
            _updateRate      = 1;
            _updateRateCount = 0;
            _updateTime      = 0.0f;
            Info             = null;
            Scene            = null;
            DelayDirty       = false;

            Info = new CCPhysicsWorldInfo();

            Scene = scene;

            Info.Gravity = PhysicsHelper.CCPointToCpVect(_gravity);

            var spc = Info.Space;

            spc.defaultHandler = new cpCollisionHandler()
            {
                beginFunc     = (a, s, o) => CCPhysicsWorldCallback.CollisionBeginCallbackFunc(a as cpArbiter, s, this),
                preSolveFunc  = (a, s, o) => CCPhysicsWorldCallback.CollisionPreSolveCallbackFunc(a as cpArbiter, s, this),
                postSolveFunc = (a, s, o) => CCPhysicsWorldCallback.CollisionPostSolveCallbackFunc(a as cpArbiter, s, this),
                separateFunc  = (a, s, o) => CCPhysicsWorldCallback.CollisionSeparateCallbackFunc(a as cpArbiter, s, this)
            };
        }