I'm trying to test out some collision detection with Box2d (using this method). I've added the source and headers to my XCode project, and have added a recursive ./**
to my header search paths. It appears to build fine.
Unfortunately, I can't use the collision detection methods directly, for reasons I don't understand.
CollisionTest.h:
#import <Foundation/Foundation.h>
@interface CollisionTest : NSObject
-(void)test;
@end
CollisionTest.mm:
(renamed to mm properly for access to C++ code)
#import "CollisionTest.h"
#import "Box2D.h"
@implementation CollisionTest
-(void)test {
b2CircleShape *circle1 = new b2CircleShape();
circle1->m_radius = 5.0;
b2Vec2 circle1Pos(0.0, 0.0);
b2Transform *transform1 = new b2Transform();
transform1->Set(circle1Pos, 0.0);
... ditto for circle2 ...
b2Manifold *manifold = new b2Manifold();
b2CollideCircles(&manifold, circle1, transform1, circle2, transform2);
if (manifold->pointCount > 0){
NSLog(@"collided");
} else {
NSLog(@"no collision");
}
}
@end
The circle setup code runs fine, but the compiler craps out on the b2CollideCircles
line with "No matching function for call to 'b2CollideCircles'".
Box2d.h
does not seem to include b2Collision.h
by default, so I've tried adding it to my implementation file both as #import "b2Collision.h"
as well as #import <Box2d/Collision/b2Collision.h>
, but the error remains the same.
How do I access the collision methods directly?