Game Development Reference
// [self applyForceTowardsFinger];
Now you can add the Plunger class, which I've already done in the Physic-
sBox2DPinball01 project. Listing 13-14 shows the Plunger class's interface,
which is also derived from BodySprite .
@interface Plunger : BodySprite
The Plunger class has a member variable for b2PrismaticJoint , which it's go-
ing to use to propel itself upward. A prismatic joint allows only one axis of move-
ment—a telescope bar would be a good example of a prismatic joint in the real world.
You can only move the smaller pipe inside the larger pipe, which allows the telescope
bar to be extended and retracted, but only in one direction.
Initializing the plunger is also straightforward, as Listing 13-15 shows. I edited the
plunger's physics settings in PhysicsEditor. In particular, I set the friction to a very
high value and set restitution to 0. This ensures that the ball is launched smoothly by
remaining in close contact with the plunger during the time the plunger is propelled up-