Game Development Reference
In-Depth Information
pitch:pitch
pan:0.0f
gain:gain];
}
-(void) endContactWithBumper:(Contact*)contact
{
[self playSound];
}
-(void) endContactWithPlunger:(Contact*)contact
{
[self playSound];
}
Tip Keep in mind that Box2D reports each individual contact of two colliding
objects, causing the contact methods to be called more than once for the same
two objects. In some cases, you may want to set a Bool variable to YES in or-
der to note that a contact has already happened. The corresponding contact
method should first check whether the variable is set, and if it is, skip the code.
You should later set the variable back to NO in a scheduled update method to
reenable contact events. By doing so, you can avoid contact code being run
multiple times and avoid undesirable side effects like too many sounds played
at once.
The Flippers
The final ingredients are the flippers, with which you control the action. The two flip-
pers will be controlled by touching the screen on either the left or right side, as Listing
13-22 shows.
Listing 13-22 . The Flipper Interface
#import "BodySprite.h"
typedef enum
 
 
Search Nedrilad ::




Custom Search