Shading Shapes for Debugging Purposes

Official forum for the Chipmunk2D Physics Library.
Post Reply
gheidorn
Posts: 5
Joined: Sun Jul 26, 2009 12:18 pm
Contact:

Shading Shapes for Debugging Purposes

Post by gheidorn »

I'm still wrapping my brain around how this all works and I was wondering if I could shade my shapes to see where they are on the screen when I am trying to debug things. I know in Cocos2d you can set RGB values to render color on nodes, but is there a way to do this for cpShapes? Or is there another approach I can take to help me visualize my Bodies and Shapes.
User avatar
Tam Toucan
Posts: 141
Joined: Tue Jun 23, 2009 4:26 pm
Contact:

Re: Shading Shapes for Debugging Purposes

Post by Tam Toucan »

Chipmunk is for physics only. It (rightly) knows nothing about how to draw things. You need to write your own code for that, but I'm confused because assuming you are using Chipmunk for the physics then it is providing you with the coords at which to draw your sprites. So why would you only want this for debug? i.e. You should already be drawing your sprites using the positions of your shapes.

You might mean you want a simpler view of just the exact shapes e.g. a circle, line polygon, instead of the real game graphic. For that have a look at the demo code it uses very basic openGL commands to do this. If you have lots of shapes to make up the shape of your sprite I guess this is useful.
gheidorn
Posts: 5
Joined: Sun Jul 26, 2009 12:18 pm
Contact:

Re: Shading Shapes for Debugging Purposes

Post by gheidorn »

Tam Toucan wrote:You might mean you want a simpler view of just the exact shapes e.g. a circle, line polygon, instead of the real game graphic. For that have a look at the demo code it uses very basic openGL commands to do this. If you have lots of shapes to make up the shape of your sprite I guess this is useful.
This is what I am looking for. I have a floor at the bottom of the screen and my hero, projectiles and enemies are all falling through it. I want to make sure I am making the floor correctly. Right now, it's just a background Sprite loaded onto the scene...the floor doesn't have an associated Sprite with it. But since something is going on where my moving bits are falling through the floor, I wanted a way to see what was going on.
User avatar
Tam Toucan
Posts: 141
Joined: Tue Jun 23, 2009 4:26 pm
Contact:

Re: Shading Shapes for Debugging Purposes

Post by Tam Toucan »

The demo code shows how to use openGL to draw lines, circles and polygons. Not done any iPhone stuff, but it should be fairly easy to get going since the functions are compatible with openGL ES. The "hard" bit might be how to initialize everything so you can actually call the glXXXX functions (the demos use the GLUT library for this).

BTW I assume other collisions are working? Also you say "since something is going on". So does some kind of effect happen when the object hit the floor or is it as though it isn't there?
gheidorn
Posts: 5
Joined: Sun Jul 26, 2009 12:18 pm
Contact:

Re: Shading Shapes for Debugging Purposes

Post by gheidorn »

After a bit of refactoring I realized that I was returning 0 from my collision callbacks, which is why things were falling through the floor. Doh! :oops:
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests