can anyone help me to remove shape and body after a delay in collision callback.
By using cpSpaceAddPostStepCallback(sapce, (cpPostStepFunc)postStepRemove, blockShape, NULL);
i could safely remove the shape .
But i need some delay before i call the function.
Can anyone please help me with some sample code.
Thanks
How to remove shape and body after a delay in collision call
-
- Posts: 3
- Joined: Mon Nov 08, 2010 10:52 am
- Contact:
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: How to remove shape and body after a delay in collision call
You asked this same question a couple days ago, but Chipmunk doesn't have any timer functionality in it. There are some Cocos2D users here, but you are much more likely to find somebody that knows how to use them on the Cocos2D forums.
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: 81
- Joined: Fri Aug 27, 2010 1:00 am
- Contact:
Re: How to remove shape and body after a delay in collision call
Hi
I didn't answer in the previous thread because I thought scotts was enough
approach your problem this way:
the "delay" you want has nothing to do with chipmunk.
therefore what you want to do is:
- detect the collision you want
- save the cpShape that you'll want to remove.
- start a timer, count a certain number a frames, draw random numbers until you get on a predefined one ... however you want to handle your delay.
- when this delay has passed use a callback method to tirgger the cpSpaceAddPostStepCallback
and there you have removed your object with a delay.
I would draw your attention to the following point:
is this what you want to do with chipmunk, the situation you describes isn't very physically realistic. I mean its like you throw a tomato on a wall, it bounces off and then explodes ^^. I saw some cases like in angry birds where the birds rolls about on the floor after impact, but in general if you object is "dead" should it be interacting with the physics. In my case I had to launch animations after impact (little explosions) but I removed the object in post collision so that is looked like the object had flown straight through.
I didn't answer in the previous thread because I thought scotts was enough
approach your problem this way:
the "delay" you want has nothing to do with chipmunk.
therefore what you want to do is:
- detect the collision you want
- save the cpShape that you'll want to remove.
- start a timer, count a certain number a frames, draw random numbers until you get on a predefined one ... however you want to handle your delay.
- when this delay has passed use a callback method to tirgger the cpSpaceAddPostStepCallback
and there you have removed your object with a delay.
I would draw your attention to the following point:
is this what you want to do with chipmunk, the situation you describes isn't very physically realistic. I mean its like you throw a tomato on a wall, it bounces off and then explodes ^^. I saw some cases like in angry birds where the birds rolls about on the floor after impact, but in general if you object is "dead" should it be interacting with the physics. In my case I had to launch animations after impact (little explosions) but I removed the object in post collision so that is looked like the object had flown straight through.
-
- Posts: 3
- Joined: Mon Nov 08, 2010 10:52 am
- Contact:
Re: How to remove shape and body after a delay in collision call
thanx for the reply
Who is online
Users browsing this forum: No registered users and 25 guests