OK...what is the best way to remove a shape upon collision then?Don't remove shapes in collision callbacks
active2staticIter crashing application
-
- Posts: 4
- Joined: Sun Nov 08, 2009 6:31 pm
- Contact:
Re: active2staticIter crashing application
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: active2staticIter crashing application
You need to add them to a list or mark a boolean on your game objects to mark them for removal. Then after cpSpaceStep() returns it is safe to remove the objects. Be careful not to remove or free the same object twice.
Just this weekend, I was working on a callback system that runs just before cpSpaceStep() exits. It should make it easy to queue up removing/freeing chipmunk objects, and flexible enough to allow you to remove entire game objects from your game scene. It also nicely solves the problem of how to prevent removing/freeing an object more than once. Currently only available in the latest trunk code, it works great but is completely undocumented and I haven't quite settled on what the API should look like so I haven't put the function prototypes in the headers yet.
Just this weekend, I was working on a callback system that runs just before cpSpaceStep() exits. It should make it easy to queue up removing/freeing chipmunk objects, and flexible enough to allow you to remove entire game objects from your game scene. It also nicely solves the problem of how to prevent removing/freeing an object more than once. Currently only available in the latest trunk code, it works great but is completely undocumented and I haven't quite settled on what the API should look like so I haven't put the function prototypes in the headers yet.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: active2staticIter crashing application
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Who is online
Users browsing this forum: No registered users and 12 guests