Created
July 2, 2012 15:54
-
-
Save slembcke/3033927 to your computer and use it in GitHub Desktop.
ChipmunkCocosBody
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ChipmunkCocosBody.h" | |
@implementation ChipmunkCocosBody | |
@synthesize syncedNodes = _syncedNodes; | |
static void | |
UpdatePosition(cpBody *body, cpFloat dt) | |
{ | |
cpBodyUpdatePosition(body, dt); | |
for(CCNode *node in ((ChipmunkCocosBody *)body->data)->_syncedNodes){ | |
node.position = body->p; | |
node.rotation = CC_RADIANS_TO_DEGREES(-body->a); | |
} | |
} | |
- (id)initWithMass:(cpFloat)mass andMoment:(cpFloat)moment | |
{ | |
if((self = [super initWithMass:mass andMoment:moment])){ | |
self.body->position_func = UpdatePosition; | |
} | |
return self; | |
} | |
- (void)dealloc | |
{ | |
self.syncedNodes = nil; | |
[super dealloc]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment