Game Development Reference
In-Depth Information
@private
NSObject* otherObject;
b2Fixture* ownFixture;
b2Fixture* otherFixture;
b2Contact* b2contact;
}
-(id) initWithObject:(NSObject*)otherObject_
otherFixture:(b2Fixture*)otherFixture_
ownFixture:(b2Fixture*)ownFixture_
b2Contact:(b2Contact*)b2contact_;
@end
@implementation Contact
-(id) initWithObject:(NSObject*)otherObject_
otherFixture:(b2Fixture*)otherFixture_
ownFixture:(b2Fixture*)ownFixture_
b2Contact:(b2Contact*)b2contact_
{
self = [super init];
if (self)
{
otherObject = otherObject_;
otherFixture = otherFixture_;
ownFixture = ownFixture_;
b2contact = b2contact_;
}
return self;
}
@end
The only notable aspect of the Contact class is that you can't keep the contact for
later use. The notifyAB method sets the object to nil immediately after the con-
tactSelector message was sent to indicate that it's only a temporary object. Direc-
tly after the call to the Box2D contact methods, the b2Contact object is released by
Box2D, and so the otherFixture , ownFicture , and b2contact pointers will
be invalid, and accessing them would cause a crash.
Search Nedrilad ::




Custom Search