Game Development Reference
In-Depth Information
return self;
+(id) flipperWithWorld:(b2World*)world flipperType:(EFlipperType)flipperType
return [[self alloc] initWithWorld:world flipperType:flipperType];
-(void) cleanup
[super cleanup];
// stop listening to touches
[[CCDirector sharedDirector].touchDispatcher removeDelegate:self];
The Flipper class also registers itself with the CCTouchDispatcher to receive
touch input events. The common misconception is that only the CCLayer class can re-
ceive input, but in fact CCLayer is merely conveniently preconfigured to receive
touches. Any class can register itself with the CCTouchDispatcher class as a del-
egate, provided that the class also removes itself as a touch delegate, usually in the
cleanup method.
As with the other pinball elements, the flippers are added to the TableSetup class
after importing the Flipper.h file and initialized as left and right flipper by using
the EFlipperType enum from Listing 13-22 .
// Add flippers
Flipper *left = [Flipper flipperWithWorld:world flipperType:kFlipperLeft];
[self addChild:left];
Flipper *right = [Flipper flipperWithWorld:world flipperType:kFlipperRight];
[self addChild:right];
Search Nedrilad ::

Custom Search