You’ve surely noticed that as the ball bounces back and forth between the obstacles, it quickly zooms out of control. The high restitution values on the bumpers and targets increase the speed of the ball with every hit. As the ball ricochets around long enough, it picks up speed that even the best human couldn’t handle. We want the restitution to increase the speed of the ball, but we want to cap the ball’s rebound speed to keep the game playable.
More trigonometry to the rescue! Let’s write a method named capPhysicsBody:atSpeed: that we can call to slow down any physics body we want in the scene.
- (void)capPhysicsBody:(SKPhysicsBody *)body atSpeed:(CGFloat)maxSpeed ...