How to set collision type for game like crayon ball?
-
- Posts: 12
- Joined: Fri Apr 23, 2010 11:36 pm
- Contact:
Re: How to set collision type for game like crayon ball?
I see, Im using different way now, the ballShapeArray is declared inside AppDelegate, I can access it now
Now im having problem with removing the ball
May I know when ball A and ball B collided, how many callback does it call?
Does it call 2 times? or only 1 time?
And can you give me example of what is the correct syntax to remove a ball?
Many thanks for your help
Now im having problem with removing the ball
May I know when ball A and ball B collided, how many callback does it call?
Does it call 2 times? or only 1 time?
And can you give me example of what is the correct syntax to remove a ball?
Many thanks for your help
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: How to set collision type for game like crayon ball?
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: 12
- Joined: Fri Apr 23, 2010 11:36 pm
- Contact:
Re: How to set collision type for game like crayon ball?
its almost working now
now the problem left is, when i remove the ball the separate callback also called and inside there i have checking that access the ball. If 1 of the ball has been removed it will be unaccesible
Im using the separate callback to update
I tried by checking all these but doesnt work
if (a->body->data != nil)
if (&a!=NULL && &b!=NULL)
Is there anyway to check if the ball is still accessible?
now the problem left is, when i remove the ball the separate callback also called and inside there i have checking that access the ball. If 1 of the ball has been removed it will be unaccesible
Im using the separate callback to update
I tried by checking all these but doesnt work
if (a->body->data != nil)
if (&a!=NULL && &b!=NULL)
Is there anyway to check if the ball is still accessible?
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: How to set collision type for game like crayon ball?
No, that's not possible. You would have to store that somewhere else.
At least in the trunk version of Chipmunk (and I think the latest released version too) the separate callback is called as soon as you remove an object from the space. That should solve your problem. Though what exactly are you doing in the separate callback?
At least in the trunk version of Chipmunk (and I think the latest released version too) the separate callback is called as soon as you remove an object from the space. That should solve your problem. Though what exactly are you doing in the separate callback?
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: 12
- Joined: Fri Apr 23, 2010 11:36 pm
- Contact:
Re: How to set collision type for game like crayon ball?
im using the separate callback to update array that store connection between balls.
I determine which ball connected with which ball with that array and update it when begin and separate callback is called
Are you also doing that with the crayonball? or am i going to wrong direction?
Please help me with some tips
Many thanks
I determine which ball connected with which ball with that array and update it when begin and separate callback is called
Are you also doing that with the crayonball? or am i going to wrong direction?
Please help me with some tips
Many thanks
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: How to set collision type for game like crayon ball?
We just rebuild the array every frame using the preSolve callback. It avoids a lot of issues.
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: 12
- Joined: Fri Apr 23, 2010 11:36 pm
- Contact:
Re: How to set collision type for game like crayon ball?
Hi,
Thank you for the tips,
I try to remove the ball by using postStepRemove and this command:
cpSpaceRemoveBody(appDelegate.space, (cpBody *)shape->body);
cpBodyFree((cpBody *)shape->body);
cpSpaceRemoveShape(appDelegate.space, (cpShape *)shape);
cpShapeFree((cpShape *)shape);
Other ball can pass through it but the ball still visible in the display
Am I missing anything?
How do i remove the ball completely from space?
Thank you
Thank you for the tips,
I try to remove the ball by using postStepRemove and this command:
cpSpaceRemoveBody(appDelegate.space, (cpBody *)shape->body);
cpBodyFree((cpBody *)shape->body);
cpSpaceRemoveShape(appDelegate.space, (cpShape *)shape);
cpShapeFree((cpShape *)shape);
Other ball can pass through it but the ball still visible in the display
Am I missing anything?
How do i remove the ball completely from space?
Thank you
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: How to set collision type for game like crayon ball?
Chipmunk doesn't know about drawing anything. You must have forgotten to remove the sprite from your scene.
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: 12
- Joined: Fri Apr 23, 2010 11:36 pm
- Contact:
Re: How to set collision type for game like crayon ball?
I tried to remove the sprite but still have error
The problem might be in my logic, i temporarily use moving the ball out of the display area when collision happen, it works for now
Now i need to check on how many connected balls when collision happen, I try to draw primitive line with ccDrawLine but it seems that the line is appearing behind the balls
Is there anyway to draw primitive line in front of the ball?
Thanks
The problem might be in my logic, i temporarily use moving the ball out of the display area when collision happen, it works for now
Now i need to check on how many connected balls when collision happen, I try to draw primitive line with ccDrawLine but it seems that the line is appearing behind the balls
Is there anyway to draw primitive line in front of the ball?
Thanks
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: How to set collision type for game like crayon ball?
You should ask these questions in the Cocos2D forums. While a few people here use Cocos2D, you will get much better answers there.
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: Heise IT-Markt [Crawler] and 9 guests