addCollider() публичный статический Метод

adds the collider to the physics system
public static addCollider ( Collider collider ) : void
collider Collider Collider.
Результат void
Пример #1
0
        public void addColliders()
        {
            if (collisionLayer == null || !_shouldCreateColliders)
            {
                return;
            }

            // fetch the collision layer and its rects for collision
            var collisionRects = collisionLayer.getCollisionRectangles();

            // create colliders for the rects we received
            _colliders = new Collider[collisionRects.Count];
            for (var i = 0; i < collisionRects.Count; i++)
            {
                var collider = new BoxCollider(
                    collisionRects[i].X + _localOffset.X,
                    collisionRects[i].Y + _localOffset.Y,
                    collisionRects[i].Width,
                    collisionRects[i].Height);
                collider.physicsLayer = physicsLayer;
                collider.entity       = entity;
                _colliders[i]         = collider;

                Physics.addCollider(collider);
            }
        }
Пример #2
0
 /// <summary>
 /// the parent Entity will call this at various times (when added to a scene, enabled, etc)
 /// </summary>
 public virtual void registerColliderWithPhysicsSystem()
 {
     // entity could be null if proper such as origin are changed before we are added to an Entity
     if (_isParentEntityAddedToScene)
     {
         Physics.addCollider(this);
     }
 }
Пример #3
0
        void addColliders()
        {
            if (_collisionLayer == null)
            {
                return;
            }

            // fetch the collision layer and its rects for collision
            var collisionRects = _collisionLayer.getCollisionRectangles();
            var renderPosition = entity.transform.position + _localPosition;

            // create colliders for the rects we received
            _colliders = new Collider[collisionRects.Count];
            for (var i = 0; i < collisionRects.Count; i++)
            {
                var collider = new BoxCollider(collisionRects[i].X + renderPosition.X, collisionRects[i].Y + renderPosition.Y, collisionRects[i].Width, collisionRects[i].Height);
                collider.entity = entity;
                _colliders[i]   = collider;

                Physics.addCollider(collider);
            }
        }