Class

SKPhysicsWorld

The driver of the physics engine in a scene; it exposes the ability for you to configure and query the physics system.

Declaration

@interface SKPhysicsWorld : NSObject

Overview

SKPhysicsWorld runs the physics engine of a scene and is the place that contact detection occurs. Do not create a SKPhysicsWorld directly; the system creates a physics world and adds it to the scene's physicsWorld property.

The physics world allows you to:

  • Set important properties like gravity

  • Join two physics bodies using an SKPhysicsJoint

  • Respond to collision between two physics bodies using contactDelegate

  • Do custom collisions detection or hit testing

Topics

Configuring the Physics World

gravity

A vector that specifies the gravitational acceleration applied to physics bodies in the physics world.

speed

The rate at which the simulation executes.

Joining Physics Bodies with Joints

- addJoint:

Adds a joint to the physics world.

- removeAllJoints

Removes all joints from the physics world.

- removeJoint:

Removes a specific joint from the physics world.

Detecting Collisions

contactDelegate

A delegate that is called when two physics bodies come in contact with each other.

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.

- bodyAlongRayStart:end:

Searches for the first physics body that intersects a ray.

- bodyAtPoint:

Searches for the first physics body that contains a point.

- bodyInRect:

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

- enumerateBodiesAlongRayStart:end:usingBlock:

Enumerates all the physics bodies in the scene that intersect a ray.

- enumerateBodiesAtPoint:usingBlock:

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

- enumerateBodiesInRect:usingBlock:

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

Sampling Physics Fields

- sampleFieldsAt:

Samples all of the field nodes in the scene and returns the summation of their forces at that point.

Relationships

Inherits From

Conforms To

See Also

Physics Simulation

Getting Started with Physics

Simulate gravity, acceleration, collision detection, or joints.

SKPhysicsBody

An object that adds physics simulation to a node.

SKPhysicsContact

A description of the contact between two physics bodies.

SKPhysicsContactDelegate

Methods your app can implement to respond when physics bodies come into contact.

SKFieldNode

A node that applies physics effects to nearby nodes.