At this point we have a world, we have edges to hold everything in, and we have a ball. Now we need to get it all moving. As you might expect, we handle this in the update
method.
-(void)update:(ccTime)dt { // Step the world forward world->Step(dt, 10, 10); // Iterate through all bodies in the world for(b2Body *b = world->GetBodyList(); b;b=b->GetNext()) { if (b->GetUserData() != NULL) { // Get the sprite for this body PhysicsSprite *sprite = (PhysicsSprite*)b->GetUserData(); // Speed clamp for balls if (sprite.tag == kBall) { static int maxSpeed = 15; b2Vec2 velocity = b->GetLinearVelocity(); float32 speed = velocity.Length(); if (speed > maxSpeed) { b->SetLinearDamping(0.5); } else if (speed < maxSpeed) { b->SetLinearDamping(0.0); } ...