Create a physics scene with bouncing objects

I’m new with Physics in game development, and I’m trying to order concepts in my mind. I wanted to create a scene like this:

http://cocos2d-x.org/programmersguide/12-img/CorrelationSprite.gif

I am following this guide: http://cocos2d-x.org/programmersguide/12/

But I don’t know how can I do to get my sprites bounce on touching the edges of the scene. Do I need to define 4 physics bodies around the scene? Do I need to control the collision and change the direction, or Chipmunk does it for me?

Thanks for your answers!

Well, today is your lucky day!

We have samples that go along with the Programmers Guide!

Here is that sample:

For how the bodies are bouncing off the edge of the Scene:

Enjoy!

Thank you very much!

This is what I needed :smile:

auto node = Node::create();
auto physicsBody = PhysicsBody::createEdgeBox(visibleSize,PhysicsMaterial(0.1f, 1, 0.0f));
node->setPhysicsBody(physicsBody);
node->setPosition(s_centre);
this->addChild(node);