Hello chipmunkers,
I am looking for a way to remove shapes and their graphics when a collision occur. As I use Python, I could extend the Poly class to add a pointer to the other one linking graphics and physics. What do you think about this first solution, and what would I do if I decide to remake it in C?
Advanced collision pair functions
-
- Posts: 4
- Joined: Fri Mar 07, 2008 3:47 am
- Contact:
-
- Posts: 4
- Joined: Fri Mar 07, 2008 3:47 am
- Contact:
Re: Advanced collision pair functions
I think I will make the top class check if the shape still exist and if it is not, destroy the graphics and itself. But it doesn't look a gracefull solution to me.
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Advanced collision pair functions
You should make a list of all of the objects that you want to remove. In the collision pair function add the objects to this list. After the cpSpaceStep() call returns (or whatever it is in the python binding) then you can remove the shapes and bodies from the space. In the C API at least, removing objects during the collision callback is forbidden as it will likely cause nasty crashes. I don't know if the python binding has some sort of protection against this.
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/
-
- Posts: 4
- Joined: Fri Mar 07, 2008 3:47 am
- Contact:
Who is online
Users browsing this forum: No registered users and 4 guests