Editing the Step method within b2World.cpp
Posted: Thu Oct 03, 2013 7:58 pm
I'm trying to destroy a body in my world upon collision with another body, and I'm doing so (following your tutorials) by putting the body to be destroyed into a vector so that I can call DestroyBody on it after the current timestep. I'm just having trouble figuring out where exactly in the code to call it.
I tried editing the Step method in b2World.cpp directly, calling DestroyBody at the end of this method, but I'm getting a series of errors by doing it this way. I try to import my WorldLayer.h file to b2World, but NSObjCRuntime.h complains with about 19 errors just when I import this class. Even when I set the b2World file type to Objective-C++ source, even more cascading errors begin to appear elsewhere.
Is editing b2World directly even the best way to do this? If so, how do I approach these cascading errors? If not, where is the best place in my code to call DestroyBody on all the bodies in the vector?
By the way, thanks so much for all of your help so far - you've been a total life saver!
I tried editing the Step method in b2World.cpp directly, calling DestroyBody at the end of this method, but I'm getting a series of errors by doing it this way. I try to import my WorldLayer.h file to b2World, but NSObjCRuntime.h complains with about 19 errors just when I import this class. Even when I set the b2World file type to Objective-C++ source, even more cascading errors begin to appear elsewhere.
Is editing b2World directly even the best way to do this? If so, how do I approach these cascading errors? If not, where is the best place in my code to call DestroyBody on all the bodies in the vector?
By the way, thanks so much for all of your help so far - you've been a total life saver!