Chipmunk Free() problem
BlitzMax Forums/BlitzMax Programming/Chipmunk Free() problem
| ||
I ported a simple billiards game I had made to chipmunk http://www.blitzbasic.com/Community/posts.php?topic=73636 Everything is working except freeing shapes and bodies. I realize you have to free shapes before freeing objects but this does not solve it. Some reference still sticks around in the space which is referenced in EachBody(). I noticed there was a destroy() function associated with bodies in the c api which is not in the wrapper. Any ideas?? |
| ||
problems spots are Function doBalls(o:Object, data:Object) and Tball.Free() |
| ||
Apologies :-) Seems the shapes/objects need to be removed from the space too, which I've neglected to handle. I'll add that to the Free() method so you don't need to worry about it. |
| ||
I've committed the fixes to the repository. You'll otherwise have to wait til I get home to sort out building a proper release :-p Nice little game btw ;-) You can change doBalls() to use b.Free() again, and ball.Free() can look something like this: Method Free() If shape shape.Free() EndIf Super.Free() EndMethod The reason you should call Super.Free() is because it makes sure the body is removed from the parent space too. (like what should have happened!) :o) |
| ||
Cool - thanks for looking at it. Chipmunk seems pretty high maintenance in terms of memory management - e.g. freeing every shape on a rag doll to blow up a space zombie. Guess its nothing some higher level code couldnt fix. |