Game Development Reference
In-Depth Information
What's left is to add some bumpers by adding the following lines in the init method
of the TableSetup class, and don't forget to import the Bumper.h file. Feel free to
reposition the bumpers as you desire:
// add some bumpers
[self addBumperAt:ccp( 76, 405) inWorld:world];
[self addBumperAt:ccp(158, 415) inWorld:world];
[self addBumperAt:ccp(239, 375) inWorld:world];
[self addBumperAt:ccp( 83, 341) inWorld:world];
[self addBumperAt:ccp(157, 294) inWorld:world];
[self addBumperAt:ccp(260, 286) inWorld:world];
[self addBumperAt:ccp( 67, 228) inWorld:world];
[self addBumperAt:ccp(183, 189) inWorld:world];
To make adding bumpers more convenient, I added the method addBumperAt to the
TableSetup class:
-(void) addBumperAt:(CGPoint)pos inWorld:(b2World*)world
Bumper* bumper = [Bumper bumperWithWorld:world position:pos];
[self addChild:bumper];
Have a look now and try how the bumpers feel in the PhysicsBox2DPinball01
project—pretty close to actual pinball bumpers, I think.
The Plunger
I hate to take control away from you, but for now I must. You're adding the plunger
now, and being able to control the ball with your fingers might get in the way. So, go
into the Ball class's update method and comment out the call to applyFor-
ceTowardsFinger :
if (moveToFinger == YES)
// disabled: no longer needed
Search Nedrilad ::

Custom Search