Game Development Reference
In-Depth Information
Orientation, Singletons, Tests, and API
This section summarizes three aspects of cocos2d that don't receive the attention they
deserve—or in the case of the Singleton pattern, perhaps they receive too much.
Singletons are often singled out as bad practice, with some developers even going as
far as stating that no project should ever use them. Pragmatists like me, though, have
yet to see a game engine or game project that didn't use singletons, and reasonably so.
Then there are cocos2d test cases and the API references, both helpful resources that
can help answer your questions—if only you knew where to look for them. But I'd like
to start off by explaining how to get your app locked to a certain device orientation.
Orientation Course in Device Orientation
More often than not, you want to lock your app to be used only in one of the four pos-
sible device orientations, or at least in either Landscape or Portrait modes.
I'll start with Kobold2D because it just works like any other Cocoa Touch app. Ko-
bold2D respects the Supported Device Orientations setting of the target. Select your
project's target, go to the Summary tab, and you'll find the Supported Device Orienta-
tions setting under the iPhone / iPad Deployment Info heading. By default, all four
device orientations are supported. To restrict the app to Landscape orientations, simply
deselect the Portrait orientations as shown in Figure 3-17 . That's really all you need to
Search Nedrilad ::

Custom Search