Game Development Reference
In-Depth Information
if (director.currentDeviceIsIPad)
platform = @"iPad";
if (director.currentDeviceIsSimulator)
platform = [NSString stringWithFormat:@"%@ Simulator", platform];
}
else if (director.currentPlatformIsMac)
{
platform = @"Mac OS X";
}
CCLabelTTF* platformLabel = [CCLabelTTF labelWithString:platform
fontName:@"Arial"
fontSize:24];
platformLabel.position = director.screenCenter;
platformLabel.color = ccYELLOW;
[self addChild:platformLabel];
glClearColor(0.2f, 0.2f, 0.4f, 1.0f);
}
return self;
}
@end
Notice the way I determine the platform (iOS, Mac OS) and device type (iPad, iOS
Simulator) using director properties such as currentPlatformIsIOS and cur-
rentDeviceIsSimulator . These are some of the extensions to CCDirector I
mentioned earlier.
You may be wondering why I haven't used preprocessor macros like
__IPHONE_OS_VERSION_MAX_ALLOWED to determine platform and device type.
First, in Kobold2D I wouldn't have used the hard-to-remember and verbose SDK mac-
ros. Instead, Kobold2D provides the simpler macros KK_PLATFORM_IOS and
KK_PLATFORM_MAC to differentiate between the two supported platforms. If needed,
Search Nedrilad ::




Custom Search