3

I'm just starting on making an Asteroids clone game in java for a class. This is my first time working with Box2D, so I'm trying to make sure I understand the basics of the class hierarchy.

One thing I'm confused about is something in the Box2D manual. When talking about how to make different bodies, it starts talking about a "ground body", which is static. Is a ground body a recommended part of the world hierarchy? Or is it just something to use as a surface for other bodies to rest on? If it is just a surface, should I use one in an Asteroids game?

I'm looking through a couple of the physics demonstrations in the example testbed. The closest one to Asteroids is called "Apply Force", and it has a ground body, even though it doesn't really have a ground.

Any explanation on how this works would really be helpful

slugster
  • 49,403
  • 14
  • 95
  • 145
DementedDr
  • 177
  • 2
  • 15

2 Answers2

2

I think you should have a ground body with isSensor = YES set. This way you will not have any collisions on the ground body. So Your objects will pass through. And also you can check if your objects touches the sensor then you may want to delete the object which is offscreen. Or else you have to make your own arrangements to check when an object is offscreen and then delete.

SaffronState
  • 329
  • 1
  • 12
1

It's not necessary, but if you don't have one everything falls through the bottom of the screen.

Possible problem? If you ran the program for a long time things might loop back through the top apart from that

Brenton Thomas
  • 618
  • 1
  • 7
  • 17