Chipmunk2D Pro API Reference  7.0.1
 All Classes Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
ChipmunkBody.h
1 /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to deal
5  * in the Software without restriction, including without limitation the rights
6  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7  * copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19  * SOFTWARE.
20  */
21 
22 @class ChipmunkShape;
23 @class ChipmunkConstraint;
24 
29 @interface ChipmunkBody : NSObject <ChipmunkBaseObject>
30 
33 +(ChipmunkBody *)bodyFromCPBody:(cpBody *)body;
34 
39 + (id)bodyWithMass:(cpFloat)mass andMoment:(cpFloat)moment;
40 
44 + (id)staticBody;
45 
49 + (id)kinematicBody;
50 
55 - (id)initWithMass:(cpFloat)mass andMoment:(cpFloat)moment;
56 
58 @property(nonatomic, assign) cpBodyType type;
59 
61 @property(nonatomic, assign) cpFloat mass;
62 
64 @property(nonatomic, assign) cpFloat moment;
65 
67 @property(nonatomic, assign) cpVect centerOfGravity;
68 
70 @property(nonatomic, assign) cpVect position;
71 
73 @property(nonatomic, assign) cpVect velocity;
74 
76 @property(nonatomic, assign) cpVect force;
77 
79 @property(nonatomic, assign) cpFloat angle;
80 
82 @property(nonatomic, assign) cpFloat angularVelocity;
83 
85 @property(nonatomic, assign) cpFloat torque;
86 
88 @property(nonatomic, readonly) cpTransform transform;
89 
91 @property(nonatomic, readonly) cpBody *body;
92 
97 @property(nonatomic, assign) id userData;
98 
100 @property(nonatomic, readonly) bool isSleeping;
101 
103 @property(nonatomic, readonly) cpFloat kineticEnergy;
104 
106 @property(nonatomic, readonly) ChipmunkSpace *space;
107 
112 - (cpVect)localToWorld:(cpVect)v;
113 
118 - (cpVect)worldToLocal:(cpVect)v;
119 
124 - (cpVect)velocityAtLocalPoint:(cpVect)p;
125 
130 - (cpVect)velocityAtWorldPoint:(cpVect)p;
131 
137 - (void)applyForce:(cpVect)force atLocalPoint:(cpVect)point;
138 - (void)applyForce:(cpVect)force atWorldPoint:(cpVect)point;
139 
145 - (void)applyImpulse:(cpVect)impulse atLocalPoint:(cpVect)point;
146 - (void)applyImpulse:(cpVect)impulse atWorldPoint:(cpVect)point;
147 
149 - (void)activate;
150 
152 - (void)activateStatic:(ChipmunkShape *)filter;
153 
160 - (void)sleepWithGroup:(ChipmunkBody *)group;
161 
165 - (void)sleep;
166 
168 - (NSArray *)shapes;
169 
171 - (NSArray *)constraints;
172 
174 typedef void (^ChipmunkBodyArbiterIteratorBlock)(cpArbiter *arbiter);
175 
177 - (void)eachArbiter:(ChipmunkBodyArbiterIteratorBlock)block;
178 
180 - (void)addToSpace:(ChipmunkSpace *)space;
182 - (void)removeFromSpace:(ChipmunkSpace *)space;
183 
186 -(void)updateVelocity:(cpFloat)dt gravity:(cpVect)gravity damping:(cpFloat)damping;
187 
190 -(void)updatePosition:(cpFloat)dt;
191 
192 @end