Box2d example online dating
Create Body(&ball Body Def); b2Circle Shape circle; circle.m_radius = 26.0/PTM_RATIO; b2Fixture Def ball Shape Def; ball Shape Def.shape = &circle; ball Shape Def.density = 1.0f; ball Shape Def.friction = 0.2f; ball Shape Def.restitution = 0.8f; _body- The last thing in the method is to schedule a method named tick to be called as often as possible.
This tutorial helps get you started with Box2D with Cocos2D by showing you how to create a simple app that shows a ball that you can bounce around the screen by rotating your i Phone with the accelerometer.
This tutorial is based on an excellent example by Kyle from i Phone Dev.net, but updated to the latest version of Cocos2D and with some more detailed explanations of how things work.
However, for this tutorial we’re going to stay as-is. Add this after your init method: The first thing we do here is to call the “Step” function on the world so it can perform the physics simulation.
The two parameters here are velocity iterations and position iterations – you should usually set these somewhere in the range of 8-10.
Ok so now that we have a basic understanding of how things should work, let’s see it in code!