Instance Method

body(in:)

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

Declaration

func body(in rect: CGRect) -> SKPhysicsBody?

Parameters

rect

A rectangle in scene coordinates.

Return Value

The first physics body discovered that intersects the rectangle. If no body intersects the rectangle, this method returns nil.

See Also

Searching the Scene for Physics Bodies

Searching the World for Physics Bodies

Cast a ray to find the physics bodies in the scene that intersect it.

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 enumerateBodies(at: CGPoint, using: (SKPhysicsBody, UnsafeMutablePointer<ObjCBool>) -> Void)

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

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

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