Question about Box 2D/ iPhone tutorial

Hello,
I am working on this tutorial about using Box2D with the iPhone...

http://www.drobnik.com/touch/2010/05/ph ... r-gravity/

It works fine. essentially a bunch of colored blocks fall to the bottom of the screen.
What I would like to do is to be able to turn off the gravity for one of those blocks.

I have emailed the author of the tutorial and he said:

"to "turn off gravity" you simply change the type of the object to static."

I asked for more clarification and he said:

"Just change the value for a single physical object."

I'm lost. I have no idea how to do that or where I would do it.
Any help would be appreciated!
Quote:
I have no idea how to do that or where I would do it.

Unless this part of the API has changed recently, you set the body type (dynamic, static, etc.) when you create the body. In fact, if you look at the code provided with the tutorial you linked to, you can see where a body's type has been set to 'dynamic'.

If you need an example, check out the testbed examples - I'm sure there are some that use static bodies, so you should be able to find an example of how to make a body static. I imagine it's also covered in the documentation (although I'm not sure what the state of the documentation is these days, I would guess that basic API details such as body types are correct and up-to-date).

If that doesn't answer your question, perhaps you could explain in a little more detail what you're hung up on.
Hi Jesse,
I am able to make the body static if I want to or change it back to dynamic with no trouble.


Here is the first part of the code in question...

-(void)addPhysicalBodyForView:(UIView*)physicalView
{
// Define the dynamic body.
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody; ....

All of the UIViews will either be dynamic or static, depending on how it is defined.
I'm wondering how to have some UIViews dynamic and some static.
Quote:
All of the UIViews will either be dynamic or static, depending on how it is defined.
I'm wondering how to have some UIViews dynamic and some static.

You'll need to revise the code so that the body type can be specified on a per-UIView basis.

From what you've posted so far, this seems less a Box2D-related problem and more a simple (trivial, in fact) programming problem. Can you perhaps clarify where you're getting hung up? That might make it easier to help.

Original thread: https://box2d.org/forum/viewtopic.php?t=4982