Instance Method

enumerateBodies(in:using:)

Enumerates all the physics bodies in the scene that intersect the specified rectangle.

Declaration

func enumerateBodies(in rect: CGRect, using block: @escaping (SKPhysicsBody, UnsafeMutablePointer<ObjCBool>) -> Void)

Parameters

rect

A rectangle in scene coordinates.

block

A block to be called for each physics body that contains the point. The block takes the following parameters:

body

The physics body that intersected the rectangle.

stop

A pointer to a Boolean variable. Your block can set this to true to terminate the enumeration.

See Also

Searching for Bodies in the World

func body(alongRayStart: CGPoint, end: CGPoint) -> SKPhysicsBody?

Searches for the first physics body that intersects a ray.

func body(at: CGPoint) -> SKPhysicsBody?

Searches for the first physics body that contains a point.

func body(in: CGRect) -> SKPhysicsBody?

Searches for the first physics body that intersects the specified rectangle.

func enumerateBodies(at: CGPoint, using: (SKPhysicsBody, UnsafeMutablePointer<ObjCBool>) -> Void)

Enumerates all the physics bodies in the scene that contain a point.