刚好帮同事做Openfeit平台,顺便给写个添加openfeint的图文步骤
1.打开http://www.openfeint.com/,点击左上角的Developers
2.注册openfeint,登录,找到downloads界面,下载最新的openfeint
3.打开SDK,把openfeint文件夹拷到你的工程目录,还要一个Delegates文件,这个我有修改它SampleDelegates弄了一个,由于不能上传附件,下次有空时传到网盘在共享下,不然你也可以自己修改下MyOpenFeintSample下的SampleDelegates.
4打开你的工程,导入openfeint和Delegates文件,在other sources里的.pch文件中加入 #import "OpenFeintPrefix.pch"
5.右击工程名,选择get info.在build选项卡中,选择All Configurations和All Settings.找到Linking->Other Linker Flags,加入"-ObjC"
6.双击targets目录下的工程的target,在General选项卡中添加
- Foundation
- UIKit
- CoreGraphics
- QuartzCore
- Security
- SystemConfiguration
- libsqlite3.0.dylib
- MobileCoreServices
- CFNetwork
- AddressBook
- AddressBookUI
- GameKit
- CoreLocation
- MapKit
- libz.1.2.3.dylib
7.很关键的一步要把所有关联到openfeint的源文件都改成.mm的7.进行openfeint的初始化,在你的工程(工程名)Delegate头文件中,加入
@class MyOFDelegate; // Add for OpenFeint
#import "OpenFeint.h"
#import "MyOFDelegate.h"
MyOFDelegate *ofDelegate; // Add for OpenFeint
在你的源文件applicationDidFinishLaunching中加入
NSDictionary* settings = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight],
OpenFeintSettingDashboardOrientation, [NSNumber numberWithBool:YES],
OpenFeintSettingDisableUserGeneratedContent, nil];
ofDelegate = [MyOFDelegate new];
OFDelegatesContainer* delegates = [OFDelegatesContainer containerWithOpenFeintDelegate:ofDelegate];
[OpenFeint initializeWithProductKey:@"qAgeIQ4ozRVT5r04OsTEg"
andSecret:@"DFPK6OmLIYbhMkoPzBaHpRpaOotPmoB37FzMua0yvE"
andDisplayName:@"Snial"
andSettings:settings // see OpenFeintSettings.h
andDelegates:delegates]; // see OFDelegatesContainer.h
8.在Openfeit官网中注册一个项目,会得到相应的ProductKey和Secret
9.启动排行榜[OpenFeint launchDashboardWithHighscorePage:(NSString*)@"排行榜id";上传最高分 [OFHighScoreService setHighScore:allscore forLeaderboard:@"排行榜id" onSuccess:OFDelegate() onFailure:OFDelegate;
好久没发这么长的帖子了,由于时间仓促,难免有些遗漏,大家可以查阅官方的相关文档,欢迎大家指正交流
注:这篇有先发于泰然论坛,From mobileworm,欢迎转载