Forum
Guest |
|---|
Welcome Guest, posting in this forum requires registration. |
|
|
| Forum | |||
|---|---|---|---|
| SEO A general discussion on search engine optimisation and general online marketing Moderators: | Topics: 1 Posts: 1 | Last post by admin in Welcome to the SEO forum on September 22, 2010, 14:56 | |
| iPhone programming A general thread on iPhone, iPad and Mac programming Moderators: | Topics: 3 Posts: 3 | Last post by admin in The official introduce yourself thread on October 7, 2010, 08:40 | |
| Flash A general discussion on flash and Actionscript Moderators: | Topics: 1 Posts: 1 | Last post by admin in Flash Q&A on September 23, 2010, 03:33 | |
| New posts | No new posts |
Cool. I have just begin looking at cocos2D but am writing a game using 100% Cocoa and Core Animation which should be available on the App Store soon. I plan to do all subsequent 2D games with cocos2d once I learn it.
There is also an APRESS book coming out soon devoted entirely to cocos2d development. There is also Beginning iPhone Games Programming from APRESS which is 750 pages, which I am reading now.
Hello all. My name is Mike and I’m an iPhone/iPad/Mac programmer. I’ve been programming the Mac for 18 years and used to work at Apple.
A protocol method for seeing if an iOS device supports GameCenter:
// Header file:
#import
#import
// Defines
#define kMinGameCenterMajorOSVersionString @”4″
#define kMinGameCenterMinorOSVersionString @”1″
// Protocols
@interface UIDevice ( UIDeviceAdditions )
- (BOOL)hasGameCenterOS;
- (UIInterfaceOrientation)mapUIDeviceOrientationToUIInterfaceOrientation:(UIDeviceOrientation)orientation;
@end
=======================
// Implementation file:
#import “UIDeviceAdditions.h”
@implementation UIDevice ( UIDeviceAdditions )
#pragma mark- Game Center
///////////////////////////////////////////////////
// See if we have a valid Game Center OS running.
///////////////////////////////////////////////////
- (BOOL)hasGameCenterOS
{
Class gcClass = nil;
NSArray *systemVersionStringComponentStringsArray = nil;
NSString *systemVersionString = nil;
NSString *foundMajorSystemVersionString = nil;
NSString *foundMinorSystemVersionString = nil;
NSComparisonResult majorResult = 0;
NSComparisonResult minorResult = 0;
BOOL hasIt = NO;
BOOL keepGoing = NO;
// Check for availability of GKLocalPlayer class…
gcClass = ( NSClassFromString( @”GKLocalPlayer” ) );
// Check OS version…
systemVersionString = [ UIDevice currentDevice ].systemVersion;
if( systemVersionString )
{
// Get version string components array…
systemVersionStringComponentStringsArray = [ systemVersionString componentsSeparatedByString:kDotStringKey ];
if( systemVersionStringComponentStringsArray )
{
// Make sure we have some before accessing array or we will crash…
if( [ systemVersionStringComponentStringsArray count ] )
{
//////////////////////////////////////
// Compare 1st component to major…
//////////////////////////////////////
foundMajorSystemVersionString = [ systemVersionStringComponentStringsArray objectAtIndex:0 ];
if( foundMajorSystemVersionString )
{
majorResult = [ foundMajorSystemVersionString compare:kMinGameCenterMajorOSVersionString ];
if( ( majorResult == NSOrderedSame ) || ( majorResult == NSOrderedDescending ) )
{
// Major is good…
if( ( [ systemVersionStringComponentStringsArray count ] > 1 ) && ( majorResult == NSOrderedSame ) )
{
// Keep going because we have more than one component and we’re on version 4.x…
keepGoing = YES;
}
else if( ( majorResult == NSOrderedDescending ) && gcClass )
{
// No need to continue since we know we’re on a later *major* version than 4.x…
hasIt = YES;
}
}
}
//////////////////////////////////////////////
// Compare 2nd component to minor, if any…
//////////////////////////////////////////////
if( keepGoing )
{
foundMinorSystemVersionString = [ systemVersionStringComponentStringsArray objectAtIndex:1 ];
if( foundMinorSystemVersionString )
{
minorResult = [ foundMinorSystemVersionString compare:kMinGameCenterMinorOSVersionString ];
if( ( ( minorResult == NSOrderedSame ) || ( minorResult == NSOrderedDescending ) ) && gcClass )
{
// We’re on at least 4.x or later so return YES…
hasIt = YES;
}
}
}
}
}
}
return hasIt;
}