Chipmunk2D Pro API Reference
7.0.1
|
Rigid bodies are the basic unit of simulation in Chipmunk. More...
#import <ChipmunkBody.h>
Inherits NSObject, and <ChipmunkBaseObject>.
Public Types | |
typedef void(^ | ChipmunkBodyArbiterIteratorBlock )(cpArbiter *arbiter) |
Body/arbiter iterator callback block type. | |
Instance Methods | |
(id) | - initWithMass:andMoment: |
Initialize a rigid body with the given mass and moment of inertia. More... | |
(cpVect) | - localToWorld: |
Convert from body local to world coordinates. More... | |
(cpVect) | - worldToLocal: |
Convert from world to body local Coordinates. More... | |
(cpVect) | - velocityAtLocalPoint: |
Get the velocity of a point on a body. More... | |
(cpVect) | - velocityAtWorldPoint: |
Get the velocity of a point on a body. More... | |
(void) | - applyForce:atLocalPoint: |
Apply a force to a rigid body. More... | |
(void) | - applyImpulse:atLocalPoint: |
Apply an impulse to a rigid body. More... | |
(void) | - activate |
Wake up the body if it's sleeping, or reset the idle timer if it's active. | |
(void) | - activateStatic: |
Wake up any bodies touching a static body through shape filter Pass nil for filter to away all touching bodies. | |
(void) | - sleepWithGroup: |
Force the body to sleep immediately. More... | |
(void) | - sleep |
Equivalent to [ChipmunkBody sleepWithGroup:nil]. More... | |
(NSArray *) | - shapes |
Get a list of shapes that are attached to this body and currently added to a space. | |
(NSArray *) | - constraints |
Get a list of constraints that are attached to this body and currently added to a space. | |
(void) | - eachArbiter: |
Call block once for each arbiter that is currently active on the body. | |
(void) | - addToSpace: |
Implements the ChipmunkBaseObject protocol, not particularly useful outside of the library code. | |
(void) | - removeFromSpace: |
Implements the ChipmunkBaseObject protocol, not particularly useful outside of the library code. | |
(void) | - updateVelocity:gravity:damping: |
Override this to change the way that the body's velocity is integrated. More... | |
(void) | - updatePosition: |
OVerride this to change the way that the body's position is intgrated. More... | |
Class Methods | |
(ChipmunkBody *) | + bodyFromCPBody: |
Get the ChipmunkBody object associciated with a cpBody pointer. More... | |
(id) | + bodyWithMass:andMoment: |
Create an autoreleased rigid body with the given mass and moment. More... | |
(id) | + staticBody |
Create an autoreleased static body. | |
(id) | + kinematicBody |
Create an autoreleased kinematic body. | |
Properties | |
cpBodyType | type |
Type of the body (dynamic, kinematic, static). | |
cpFloat | mass |
Mass of the rigid body. Mass does not have to be expressed in any particular units, but relative masses should be consistent. | |
cpFloat | moment |
Moment of inertia of the body. The mass tells you how hard it is to push an object, the MoI tells you how hard it is to spin the object. Don't try to guess the MoI, use the cpMomentFor*() functions to try and estimate it. | |
cpVect | centerOfGravity |
Location of the body's center of gravity relative to it's position. Defaults to cpvzero . | |
cpVect | position |
The position of the rigid body's center of gravity. | |
cpVect | velocity |
The linear velocity of the rigid body. | |
cpVect | force |
The linear force applied to the rigid body. Unlike in some physics engines, the force does not reset itself during each step. Make sure that you are reseting the force between frames if that is what you intended. | |
cpFloat | angle |
The rotation angle of the rigid body in radians. | |
cpFloat | angularVelocity |
The angular velocity of the rigid body in radians per second. | |
cpFloat | torque |
The torque being applied to the rigid body. Like force, this property is not reset every frame. | |
cpTransform | transform |
The rigid transform of the body. | |
cpBody * | body |
Returns a pointer to the underlying cpBody C struct. | |
id | userData |
An object that this constraint is associated with. More... | |
bool | isSleeping |
Has the body been put to sleep by the space? | |
cpFloat | kineticEnergy |
Get the kinetic energy of this body. | |
ChipmunkSpace * | space |
Get the space the body is added to. | |
Rigid bodies are the basic unit of simulation in Chipmunk.
They hold the physical properties of an object (mass, position, rotation, velocity, etc.). After creating a ChipmunkBody object, you can attach collision shapes (ChipmunkShape) and joints (ChipmunkConstraint) to it.
Apply a force to a rigid body.
An offset of cpvzero is equivalent to adding directly to the force property.
force | A force in expressed in absolute (word) coordinates. |
offset | An offset expressed in world coordinates. Note that it is still an offset, meaning that it's position is relative, but the rotation is not. |
Apply an impulse to a rigid body.
impulse | An impulse in expressed in absolute (word) coordinates. |
offset | An offset expressed in world coordinates. Note that it is still an offset, meaning that it's position is relative, but the rotation is not. |
+ (ChipmunkBody *) bodyFromCPBody: | (cpBody *) | body |
Get the ChipmunkBody object associciated with a cpBody pointer.
Undefined if the cpBody wasn't created using Objective-Chipmunk.
Create an autoreleased rigid body with the given mass and moment.
Guessing the moment of inertia is usually a bad idea. Use the moment estimation functions (cpMomentFor*()).
Initialize a rigid body with the given mass and moment of inertia.
Guessing the moment of inertia is usually a bad idea. Use the moment estimation functions (cpMomentFor*()).
Convert from body local to world coordinates.
Convert a point in world (absolute) coordinates to body local coordinates affected by the position and rotation of the rigid body.
- (void) sleep |
Equivalent to [ChipmunkBody sleepWithGroup:nil].
That is the object is forced to sleep immediately, but is not grouped with any other sleeping bodies.
- (void) sleepWithGroup: | (ChipmunkBody *) | group |
Force the body to sleep immediately.
The body will be added to the same group as group
. When any object in a group is woken up, all of the bodies are woken up with it. If group
is nil, then a new group is created and the body is added to it. It is an error pass a non-sleeping body as group
. This is useful if you want an object to be inactive until something hits it such as a pile of boxes you want the player to plow through or a stalactite hanging from a cave ceiling. Make sure the body is fully set up before you call this. Adding this body or any shapes or constraints attached to it to a space, or modifying any of their properties automatically wake a body up.
- (void) updatePosition: | (cpFloat) | dt |
OVerride this to change the way that the body's position is intgrated.
You should either understand how the cpBodyUpdatePosition() function works, or use the super method.
Override this to change the way that the body's velocity is integrated.
You should either understand how the cpBodyUpdateVelocity() function works, or use the super method.
Get the velocity of a point on a body.
Get the world (absolute) velocity of a point on a rigid body specified in body local coordinates.
Get the velocity of a point on a body.
Get the world (absolute) velocity of a point on a rigid body specified in world coordinates.
Convert from world to body local Coordinates.
Convert a point in body local coordinates coordinates to world (absolute) coordinates.
|
readwritenonatomicassign |
An object that this constraint is associated with.
You can use this get a reference to your game object or controller object from within callbacks.
delegate
properties this is a weak reference and does not call retain
. This prevents reference cycles from occuring.