Game Development Reference
In-Depth Information
The system queries this method frequently to determine whether it's allowed to autoro-
tate the app to a certain interface orientation. The method should return YES if the app
supports the orientation it was passed in, and NO otherwise. You should return YES for
at least one interface orientation—otherwise iOS defaults to Portrait mode.
The iOS SDK offers two macros to test whether an interface orientation is either one of
the two Portrait modes or one of the two Landscape modes:
BOOL isLandscape = UIInterfaceOrientationIsLandscape(orientation);
BOOL isPortrait = UIInterfaceOrientationIsPortrait(orientation);
Allowing your app to rotate to both Landscape or both Portrait orientations Is recom-
mended because some users prefer the home button on the left side, others on the right
side, and others just want to use the app in the orientation they're currently holding the
device in. Therefore the decision should be left up to the user where possible.
However, there are reasons to restrict your app to one particular device orientation. For
example, if your app is accelerometer controlled, like the popular Labyrinth game, tilt-
ing the device too far in one direction could trigger autorotation inadvertently. That
could make the game unplayable. To force your app to use only a specific orientation,
compare the orientation parameter with one of the four UIInterfaceOrienta-
tion types. In this example, only the Landscape Left orientation is allowed:
return interfaceOrientation == UIInterfaceOrientationLandscapeLeft;
Note The UIInterfaceOrientationLandscapeLeft orientation is
the orientation as depicted by the Landscape Left icon in Figure 3-17 . That
means the home button is on the left side. This is important to note in case
you've been using an earlier cocos2d version where the device orientation was
used instead of the interface orientation. Whereas the device orientation used to
be set to UIDeviceOrientationLandscapeRight , you now have to
use UIInterfaceOrientationLandscapeLeft , and where
UIDeviceOrientationLandscapeLeft was used, you have to use
UIInterfaceOrientationLandscapeRight .
Search Nedrilad ::

Custom Search