Game Development Reference
AppDelegate.m and locating the method shouldAutorotateToInter-
faceOrientation . This method should return YES for all supported orientations,
otherwise it should return NO . You can use the UIInterfaceOrienta-
tionIsPortrait macro to test whether a given interface orientation is a portrait
mode. If so, it will return YES .
-(BOOL) shouldAutorotateToInterfaceOrientation: ←
Kobold2D users can also use the Supported Device Orientation buttons on the Sum-
mary tab of the application target's properties to change which orientations are suppor-
ted and which aren't.
The BodySprite Class
The idea behind the BodySprite class is that you want to use a self-contained object
for all your dynamic classes. So far, you simply added the body to the PhysicS-
prite 's physicsBody property, and it's easy to forget to add the sprite itself as
userdata to the body. The BodySprite class is designed to make the Physic-
sSprite class more self-contained.
BodySprite is derived from PhysicsSprite and therefore contains a Box2D
physicsBody property and instance variable. With all classes for the pinball game
elements being derived from the BodySprite class, you have a common class to
work with, which you can then further probe for its type. For example, you can use the
isKindOfClass method to determine at runtime from any BodySprite* pointer
which class you're working with. The isKindOfClass method is supported by all
classes that derive from NSObject .
In addition, the BodySprite class header file includes commonly used headers such
as Box2d.h and Helper.h (see Listing 13-1 ). The Helper class contains helpful
functions you've used before, such as toPixels and toMeters , as well as loca-
tionFromTouch and screenCenter . The Constants.h file contains the
PTM_RATIO because it will be needed by multiple classes.