Tuesday, January 24, 2012

Adding GameFeed to your OpenFeint Enabled Cocos2d App

In order for us to add the new GameFeed feature of OpenFeint to our Word Crank app on iOS we needed to upgrade to the latest version of OpenFeint, version 2.12.5.  After a few issues with linking errors we were finally running with the latest and greatest that OpenFeint has to offer. Complete instructions for upgrading are included here.

Next we wanted to include the GameFeed component, but only on the home screen.  We used a similar approach to how we included AdMob in the free version.  Some code snippets are included below to help others.

 

[sourcecode language="objc"]
-(id) init
{
if ( (self=[super init]) ) {

CGSize s = [[CCDirector sharedDirector] winSize];

controller = [[RootViewController alloc] init];
controller.view.frame = CGRectMake(0,0,s.width,s.height);

gameFeed = [OFGameFeedView gameFeedView];

[controller.view addSubview:gameFeed];
[[[CCDirector sharedDirector] openGLView]addSubview : controller.view];
}

return self;
}

- (void) dealloc
{
[controller.view removeFromSuperview];
[controller release];

[super dealloc];
}
[/sourcecode]

Do you know a different way to do it? Leave a comment below.

No comments:

Post a Comment