苹果game centerr里面游戏出现5个数字是啥意思?

斫`I%&/m{JJ奏t`$@炝玩iG#)*eVe]f@添槛{锝鬓{锝骱;N'鬟?\fdl鑫J谏!?~|?"O<y篼抓q丸gJ香Ef)挢押更欤j冁v*(_}枣镖pNY蒌g{{wa_oTUwvY>蝗邰-螅b5?/E度)滴goW鲲=躯/_;_k_{ほi_眈]]膨mZ珏g5螵nщ6-y[
泠bn朴jqXdys犯[V诊__-谚锒P3Um|?]f蜷GiSO]t7粟l<]蕙^找k鳔:?|t豇|龀蚁7GV放刺N.}h')nM6s^N!T M|UL汾y研;/NIめdR,.丢巫Y==}矜熨~~|镝-~哏_z2lmum_|/N聩=纬_twog?v~瑚pgo@秽^Ck16鳍哚E5)'_~!y蝽/N]蕨m^锲簌诠}P^军蛘(U^4吝32慵}尔)O
{裼紫_q尔瘢翥{>蓰x~碣匡犸}v疬黛聍[埝晚橄{~K=扉k锣{{{}夯;{`o齄揞艳~疣G)4t3dlmg_izM*仰禾y7iPzB席B?>精&桉]Y)MGLE5d涛FH{xv^i峒=|O~s嫉w;veqA}x]z)mg7DV_裹梓衮GG邕[炭fG橄7B皇en!骐t鹣o钪^g嘶% 篁b?涌jdWu滁+ (>溥~5C{|k2jX鬟g裤#W3=/翥<_岿O趸btq耧n nH铤E矶h4?MDPc喟e~㈨j:[?穹苓7u4踢芍咙I\慰聍w|RUoc茺婵V.(N茔恢
lv#&_避Tm[-眍蝣鲽
4靠|N苏8'g⒁p4=!fx[w:⒃龄="! $ Ro"+DBL w#怡EF1pぺ惜u!梭jun to寺馈# 刍刍虞O=|闯侵.?舴k_?@CK縻B51峡鸠疫7;^ ╄9骜,\铽lzRY睫TU楸#ld谳4孕C锾
i7ghq慧%6?<i镱o;FAM
+x*孥貊.%A铌押柑J`〓_g7N~烨o ? YQob乜7_w/+~Wx<G_7G?聍7]F猷/轱G屣?;W磉艨魁K 滹___oW?O
2?u?虔[?w蛏?)Si迷qK硌dA|圹*f睃蓰措证.gD\+(a:二栾p6栾U5瘩.|c+h'榍}i赀宽4}IW诂n;klz c!IUSxm芗X|W>跎>?K/cV旺wmZR wG?wW%蝻乜鞣c镞舣;?{蛇K_l骖驱o3TB }沅氽}胞`,'澌W榀唬Q(酗}/}纷{A761 gw狗{醑Wg裤{;士C_#=伫k夸_n咣I究箬廾$78n蜗f镉2慕枥w锄溲瓤?葵铒倏棼{t^璺j?-恨役9J3顿~8裒tdQ$@lAG"9yQ-/u4}eU?灬u$峨 e(ue2#究7Wu-ZlZ5d$cC甏x.涿腙
eIEa__zfzhs色',:~倏粝走s_黠R>4$S68U"L整wsE#@3F榭墅.邗2o雷8qr襦`rP&伉f Md6 #-扣bx阋札$C)Es漱AR襁jE_7}?鲞+_丝?踹 >f鹱 乜0叁踢蒴-ㄢz,.!Buzn^L w_"$}{~
G腼唼蹩b>?vIz[( Zmx!瓶SXx#ObNim`>9EJqvie3怔黠l[篼hi~{{)1遇逋}AVlFZq偌pcIVLRポ~Y<ㄇj/xg6痍|IX g4~fB;F磷|wj{+臾殒#]Q34婀buH|瑚`麻#go;/K谰岳F赌Xe_\投|w郄64+cCⅫ纛O7w迮私O7壳t都屉Θ}D!春0EEnw$t胛{钹b:{Rs┦LDPo弩</S黠e卓$_Y8s破zf憋^y a|据铭q7$'\[,0舆N_x阪骶YC}a砌3ぴc汰A??RdJA秀6&轷耦挝稔1e╆舫wodO趼WYY\,?XBuz"^M:K^谩榇EL嚎P燧镲khj渠湛檫I"人蓠xO~GoM筮貅踢oM膺3i烹U1レ z6j^\ bx杭{w?胶耕逵沱_W;/v<购Z阵o~矜y裼щ/|uv(鲞}}vwWf2o"~Sf析|l 傥~a`w3
峡O糠P7窍遄紫窥\~语xv鬻?峡砜~7ws67uC僻慰C?W=?{q蜴scG~[岑[嚎镲KoxV^|'/N~瞅辋YiE#Zx诨AgNB_[斟Ls荤F~}Rl3箦W煜 桊`玑名?W33 (眄v佩噙K蜴e);蜊框齄媒鲼J8唣碳zz俭咫铺苒?d酮#S{p35衔镛K_诳_k-影{_~~U杜P"Dj盍7<=/~'2=;{摞s翻<处L冽}] S鱿癔镞H驷_K$3d萦u{
UO|ox揖N_0-"=茺诮帆Zvz^?宽S→_xzWo尉|!蓟.NX狼蛘脒'(ジ跹k]胡=Q: KkQRO??/?/K烘猢Pv8氵3惋Zo$*F
小V0Y~Qhx#1sef卉khvIw还%麸Dz矿岑窨?g>k角肃~朕鼢<阅H哓(
pS?慰蝼]?蚩竣c?w?o5O_/#o$毓醌祉|#;ys蕨y趿傀3唪_苓蛇蝼if_g_'量X:m:?{F!┚.y$嗝o{vw=茼tN_o{_[_m趴觑缈O/'"{筋Q昧7D戥(A锟?蹩框/{o/醪菹 乌
yC:{
h鬓捷!9F孢p多7轱G隹{蘅c_?栎{唪祛祉翩耧舣Kb柳__轱婵7_O哌霹wU_鲼q撖`h;吒yG摘`铌M沁?倏-?踹劭暨|w铱赭?||7w\e}uig缌{L?聍
耧t| W邕奎吨F@}{z镟oY+)W@蓿 =溽?醑</蚩{侩?'罂7a[半蠲oh?糯粉[粤D=|鲞?G~击饔Oi镶G^}痍iqo7)(R8bo/olH呐oX?y0=龌舵稞'眶_kn峡诳3G矿- 蔸Ud黠jFLIj;)M钶 eV?wdi槠oW审'yQC[D1柄图X几靓_岿Od.E钸/hYc缶{V琦6H]~&绩d牲в,Wl9C襁蜻鼾%"a[Y[>g轿?M况 M]哚K8┇iD.魁K%oK窨#~新O:篝靡f\S跸wvn箫R2黥1]/G┛;'碚映?I圻酤1i?奸yx笼n键O钥冗7O喜k5UUVT嘘|Q:k{憬耦7=K?=Ks%(n5': jhZ浞霪Y待Y^|蹶g钛R钭 X掊x{Q箭63泣:kb?G0//D馔Oz滟7[徜7~y绞EV?o尉`'V|JxEV_30?(I竭%俳蝗e_琼葸窟 谶/?W柽Ka}C4?>iw_镉|矜磙螫o镞=?y鼽q3]4_\}z7g/~'Hc{?M苒 LTyR}]1e9[g√羡W瘟_hf教块_7卓'宽5K[蝈_-g6饼;t漭P_o_'跨啭gAP婕WozG^铎w|?T嘻O2藿o/u杩A骘魁唼g鲲爝'裤WC瘙泔!|4 ~Sb 钛螯;Y2cD巡d?癔'/~5d?'岿6c~檗?|唠$,?昼YV1{#围眚C狃 缴ovcxO蹀@
i舫*,i|@A㈨垠+w争]8mV,[WuRv8%&~*_/Sv泣'隐疬g痫膺绝蝓ApNMHz麒k"/%?hG2柽W艨虔框_婵裣/"9
2o锡A铞汲{罾 ?*c箕3菘Wq进t?镊
pp -?粝 蛇W[>5 /逻7离唿_c9ygu`{鲣oU?}:i缚?矿/~者os筷嵇?_{房mT}J棍辇瞠丝}走C?+岢V=┛qDm/o`思=Z *3殚bK赌`;}t逻/殳矿蜇3f0呃Pз痫zd(v.↓C/CG|z/旷饪k?h}!格}Y糇4御{%DO黯溢I
裒6'MO3n猁qe66~\~L 荪sj{k祸&2?gB8i5@iR"@UH"船>2G{|rs?⒖TCEzw3|O它鳢fLD8洒h7痧hAgu/秸葺|痘;{,jG/f}t^U5L岳牌!y4 02g{w岁:_1C)Uz^R
wu':d+*栎黄;踹G}-x&8涌肟@xF涂丰o服赠芽/?3汨o侩_K"_树|-r糨p伦7!E1i-y|Q]觅伤岿镖:苒?{磔Z*|粝Oe镯祆罹/H?g蹩r酵.G暹稂c嗫O框//owO0Mw7-筮uogo甾Jz[H!逻=_K|o- TG^=蒿榱惠秃樯褓盈~O~螈,_U货学g=v{RY佴>HvKOzUa崭Z悴L_Y臼季g}mJs齄`W_bY例粕eVЭd6_棘VeY旱3(^牲('G笈x5筇|惋~镔O镧名嘤 绎f~ 圹>q~缜葵SR)E|t桴 P}檑荐wZ)p=#B趱哏)gOO)髁g/ 饲璎;OM{
橘G同13163人阅读
原创,转载务必在明显处注明:转载自&原文链接:&& & & & 这里Himi给出对于开发iOS的朋友们整理一个指南集合,其中主要包括申请IDP需要注意的地方、有了开发者证书如何真机调试、在自己的游戏应用中如何接入GameCenter以及如何在游戏接入OpenFeint;& & & & -----------申请企业级IDP,或者个人IDP& & & &通过Himi的申请经验,直接打苹果在中国的客服,按照步骤一步一步详细的让客服进行指导,可能很多童鞋说我这句跟没说一样,呵呵,如果真的你是第一次申请IDP那么如果你不打客服,N多细节都会造成你1~15天耐心等待,Himi申请过程中由于一个名称和一个勾选错误整整耽误一个月的时间;最后仍是不停的跟客服交涉终于Ok顺利申请到;& & &这里Himi给出苹果在中国的客服电话: (建议拨打客服之前大致的先百度google下申请IDP的流程,网上一大堆,这里Himi不赘述了)& & &&---------------申请到IDP后如何真机调试& & &1.制作证书的过程Himi这里不多赘述,百度、google下N多文章呢;制作证书连接(前提是申请IDP成功):/membercenter/index.action& & &2.正确制作证书后,有个这样的文件:& & & & & & & & &&& & &双击此文件,弹出Organizer-Devices界面,连接你的真机iphone、ipad或者touch,然后左侧可以看到如下图:& & & & & & && & &右侧的绿色小灯表示可以正常使用,这个小灯如果是黄色,那就说明你的证书有问题,可能是此手机的UDID没有在证书内等原因;& & &3.确保真机正常后,点击你的项目,右侧点击PROJECT点击Build Settings页面,然后Code Signing下设置Code Signing Identity为你的证书,如下图:& & && & 4.点击你的项目,右侧点击TARGETS,点击Info页面下的设置Bundle identifier,这个Bundle identifier在你制作证书的过程中就会了解到,如下图:& & && OK,可以编译运行你的项目到真机中了;& & &---------------游戏接入GameCenter 指南1.&&& iTunes Connect 设置&&& 首先,申请一个应用程序,不必提交.目地是为了得到Bundle ID.&&& 然后设置一下工程中Info.plist的Bundle identifier使之与iTunes Connect中的Bundle ID相同,否则当你尝试登录GameCenter的时候,会提示一个不支持GameCenter的错误.&&& 申请完毕,打开你刚申请的application,点击Manage Game Center选项.&&& 进入后点击Enable Game Center使你的Game Center生效.&&& 接下来就可以设置自己的Leaderboard和Achievements.&2.&&& Leaderboard设置&&& Leaderboard纵观图如下所示.&&&& 1.sort Order: Leaderboard中的内容是以升序还是降序排列.&&& 2.Score Format Type:分数的类型.&&& 3.*Categories:Leaderboard的一个分数榜,这个可以创建多个,比如游戏可以分为Easy,Normal,Hard三个难度,每个难度一个榜.&&& *设置完成后保存,完成了一个 Leaderboard的设置.我们可以根据需要添加多个 leaderboard.&&& 4.**Score Format Location: leaderboard支持的语言.&&& **可以支持多种语言,每支持一种语言,需要完成一个上述操作.这个时候右下角会出现save change按钮,点击完成leaderboard的设置.你可以根据需要随时更改你的leaderboard,操作与上述内容类似.3.&&& Achievements设置&&& Achievements界面内容比较少,点击左上角的Add New Achievement,打开如下图所示的Achievements创建界面.&&& Hidden:表示该成就为解锁前玩家是否可见.&&& Achievement ID:程序通过这个属性来识别成就.&&& *Achievement Localization:该成就支持的语言.&&& *Achievement Localization设置如下图所示.&&& *其中,成就的Image必须是512X512,72DPI的.一切设置完成后,点击save change按钮即完成一个成就的设置.4.总体功能在使用各个功能前,你需要了解一下块函数。传送门:&4.1 对Game Center支持判断&&
- (BOOL) isGameCenterAvailable
Class gcClass = (NSClassFromString(@&GKLocalPlayer&));
NSString *reqSysVer = @&4.1&;
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
BOOL osVersionSupported = ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending);
return (gcClass && osVersionSupported);
}4.2用户登录& &
- (void) authenticateLocalPlayer
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error){
if (error == nil) {
//成功处理
NSLog(@&成功&);
NSLog(@&1--alias--.%@&,[GKLocalPlayer localPlayer].alias);
NSLog(@&2--authenticated--.%d&,[GKLocalPlayer localPlayer].authenticated);
NSLog(@&3--isFriend--.%d&,[GKLocalPlayer localPlayer].isFriend);
NSLog(@&4--playerID--.%@&,[GKLocalPlayer localPlayer].playerID);
NSLog(@&5--underage--.%d&,[GKLocalPlayer localPlayer].underage);
//错误处理
NSLog(@&失败
%@&,error);
}对于开发者来说,Game Center必须经过测试才能上线,没有上线的程序在测试环境中登录时会出现sandbox提示.如图.& & & & &&
4.3用户变更检测由于4.0以后系统支持多任务,玩家的机器有可能被不同的玩家接触,导致Game Center上的用户发生变化,当发生变化的时候,程序必须在游戏中通知玩家.& & - (void) registerForAuthenticationNotification
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self
selector:@selector(authenticationChanged)
name:GKPlayerAuthenticationDidChangeNotificationName
object:nil];
- (void) authenticationChanged
if ([GKLocalPlayer localPlayer].isAuthenticated)
// Insert code here to handle a successful authentication.
// Insert code here to clean up any outstanding Game Center-related classes.
}5.对Leaderboard进行操作5.1上传一个分数& &
- (void) reportScore: (int64_t) score forCategory: (NSString*) category
GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:category] autorelease];
scoreReporter.value =
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil)
// handle the reporting error
NSLog(@&上传分数出错.&);
//If your application receives a network error, you should not discard the score.
//Instead, store the score object and attempt to report the player’s process at
//a later time.
NSLog(@&上传分数成功&);
}当上传分数出错的时候,要将上传的分数存储起来,比如将SKScore存入一个NSArray中.等可以上传的时候再次尝试.5.2下载一个分数&&
//GKScore objects provide the data your application needs to create a custom view.
//Your application can use the score object’s playerID to load the player’s alias.
//The value property holds the actual value you reported to Game Center. the formattedValue
//property provides a string with the score value formatted according to the parameters
//you provided in iTunes Connect.
- (void) retrieveTopTenScores
GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init];
if (leaderboardRequest != nil)
leaderboardRequest.playerScope = GKLeaderboardPlayerScopeG
leaderboardRequest.timeScope = GKLeaderboardTimeScopeAllT
leaderboardRequest.range = NSMakeRange(1,10);
leaderboardRequest.category = @&TS_LB&;
[leaderboardRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
if (error != nil){
// handle the error.
NSLog(@&下载失败&);
if (scores != nil){
// process the score information.
NSLog(@&下载成功....&);
NSArray *tempScore = [NSArray arrayWithArray:leaderboardRequest.scores];
for (GKScore *obj in tempScore) {
: %@&,obj.playerID);
: %@&,obj.category);
: %@&,obj.date);
formattedValue
: %@&,obj.formattedValue);
: %d&,obj.value);
: %d&,obj.rank);
NSLog(@&**************************************&);
}说明:1)&&& playerScope:表示检索玩家分数范围.2)&&& timeScope:表示某一段时间内的分数3)&&& range:表示分数排名的范围4)&&& category:表示你的Leaderboard的ID.5.3玩家信息交互Game Center最重要的一个功能就是玩家交互.所以,必须检索已经登录玩家的好友信息.根据自己的需要做出设置,比如,可以与好友比较分数,或者好友排行榜等.//检索已登录用户好友列表& &
- (void) retrieveFriends
GKLocalPlayer *lp = [GKLocalPlayer localPlayer];
if (lp.authenticated)
[lp loadFriendsWithCompletionHandler:^(NSArray *friends, NSError *error) {
if (error == nil)
[self loadPlayerData:friends];
// report an error to the user.
}上面的friends得到的只是一个身份列表,里面存储的是NSString,想要转换成好友ID,必须调用- (void) loadPlayerData: (NSArray *) identifiers方法,该方法得到的array里面存储的才是GKPlayer对象.如下& &
Whether you received player identifiers by loading the identifiers for the local player’s
friends, or from another Game Center class, you must retrieve the details about that player
from Game Center.
- (void) loadPlayerData: (NSArray *) identifiers
[GKPlayer loadPlayersForIdentifiers:identifiers withCompletionHandler:^(NSArray *players, NSError *error) {
if (error != nil)
// Handle the error.
if (players != nil)
NSLog(@&得到好友的alias成功&);
GKPlayer *friend1 = [players objectAtIndex:0];
NSLog(@&friedns---alias---%@&,friend1.alias);
NSLog(@&friedns---isFriend---%d&,friend1.isFriend);
NSLog(@&friedns---playerID---%@&,friend1.playerID);
}至此,leaderboard功能介绍完毕6.对Achievement进行操作& 这一部分内容比较多,而且有的地方有点重复的感觉.6.1汇报一个成就的进度& 对于一个玩家可见的成就,你需要尽可能的报告给玩家解锁的进度;对于一个一部完成的成就,则不需要,当玩家的进度达到100%的时候,会自动解锁该成就.& & - (void) reportAchievementIdentifier: (NSString*) identifier percentComplete: (float) percent
GKAchievement *achievement = [[[GKAchievement alloc] initWithIdentifier: identifier] autorelease];
if (achievement)
achievement.percentComplete =
[achievement reportAchievementWithCompletionHandler:^(NSError *error)
if (error != nil)
//The proper way for your application to handle network errors is retain
//the achievement object (possibly adding it to an array). Then, periodically
//attempt to report the progress until it is successfully reported.
//The GKAchievement class supports the NSCoding protocol to allow your
//application to archive an achie
NSLog(@&报告成就进度失败 ,错误信息为: \n %@&,error);
//对用户提示,已经完成XX%进度
NSLog(@&报告成就进度----&成功!&);
completed:%d&,pleted);
hidden:%d&,achievement.hidden);
lastReportedDate:%@&,achievement.lastReportedDate);
percentComplete:%f&,achievement.percentComplete);
identifier:%@&,achievement.identifier);
}其中该函数的参数中identifier是你成就的ID, percent是该成就完成的百分比6.2读取一个成就方法一:得到所有的成就& & - (void) loadAchievements
NSMutableDictionary *achievementDictionary = [[NSMutableDictionary alloc] init];
[GKAchievement loadAchievementsWithCompletionHandler:^(NSArray *achievements,NSError *error)
if (error == nil) {
NSArray *tempArray = [NSArray arrayWithArray:achievements];
for (GKAchievement *tempAchievement in tempArray) {
[achievementDictionary setObject:tempAchievement forKey:tempAchievement.identifier];
completed:%d&,pleted);
hidden:%d&,tempAchievement.hidden);
lastReportedDate:%@&,tempAchievement.lastReportedDate);
percentComplete:%f&,tempAchievement.percentComplete);
identifier:%@&,tempAchievement.identifier);
}函数中NSArray返回的是你的所有成就ID.方法二:根据ID获取成就& & - (GKAchievement*) getAchievementForIdentifier: (NSString*) identifier
NSMutableDictionary *achievementDictionary = [[NSMutableDictionary alloc] init];
GKAchievement *achievement = [achievementDictionary objectForKey:identifier];
if (achievement == nil)
achievement = [[[GKAchievement alloc] initWithIdentifier:identifier] autorelease];
[achievementDictionary setObject:achievement forKey:achievement.identifier];
return [[achievement retain] autorelease];
}6.3获取成就描述和图片在自定义界面中,玩家需要一个成就描述,以及该成就的图片,Game Center提供了该功能.当然,你也可以自己在程序中完成,毕竟玩家不可能时刻处于在线状态.&&
- (NSArray*)retrieveAchievmentMetadata
//读取成就的描述
[GKAchievementDescription loadAchievementDescriptionsWithCompletionHandler:
^(NSArray *descriptions, NSError *error) {
if (error != nil)
// process the errors
NSLog(@&读取成就说明出错&);
if (descriptions != nil)
// use the achievement descriptions.
for (GKAchievementDescription *achDescription in descriptions) {
NSLog(@&1..identifier..%@&,achDescription.identifier);
NSLog(@&2..achievedDescription..%@&,achDescription.achievedDescription);
NSLog(@&3..title..%@&,achDescription.title);
NSLog(@&4..unachievedDescription..%@&,achDescription.unachievedDescription);
NSLog(@&5............%@&,achDescription.image);
//获取成就图片,如果成就未解锁,返回一个大文号
[achDescription loadImageWithCompletionHandler:^(UIImage *image, NSError *error) {
if (error == nil)
// use the loaded image. The image property is also populated with the same image.
NSLog(@&成功取得成就的图片&);
UIImage *aImage =
UIImageView *aView = [[UIImageView alloc] initWithImage:aImage];
aView.frame = CGRectMake(50, 50, 200, 200);
aView.backgroundColor = [UIColor clearColor];
[[[CCDirector sharedDirector] openGLView] addSubview:aView];
NSLog(@&获得成就图片失败&);
}如果你不主动使用注释中的方法,那么你得到的description中不会有图片,这样可以减少网络的使用,尽量少下载东西.当使用注释中的代码时,如果成就已经解锁,则返回该成就的图标,如果没有解锁,则返回一个大问号,至于未解锁图标是否可以自定义,我找寻的结果好像是不可以.GameCenter &成就提示更新:&GameCenter中成就提示需要开发者自定义,即使官方Demo的例子程序中也没有给与提示框(横幅样式)通知用户的官方代码,所以这里Himi介绍如何模仿官方的成就提示:& &1. iOS5以及更高SDK中,apple已经提供官方的成就提示:方法很简单,代码如下:- (void)sendAchievement:(GKAchievement *)achievement {
achievement.percentComplete = 100.0;
//Indicates the achievement is done
achievement.showsCompletionBanner = YES;
//Indicate that a banner should be shown
[achievement reportAchievementWithCompletionHandler:
^(NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^(void)
if (error == NULL) {
NSLog(@&Successfully sent archievement!&);
NSLog(@&Achievement failed to send... will try again \
Reason: %@&, error.localizedDescription);
}将“showsCompletionBanner”属性设置成YES,提交给苹果。新iOS属性“showsCompletionBanner”,其默认设置是NO,但若将其调整成YES,屏幕就呈现包含成就标题和描述的漂亮横幅;2.如果低于5.0的SDK设备中是没有 “showsCompletionBanner”属性的,所以需要我们自定义提示样式,当然这里Himi也分享一下如何模仿官方横幅提示样式的方法和代码:& & & 首先,我借鉴,从/typeoneerror/GKAchievementNotification中抓取一些代码植入自己的项目。我们将采用GKAchievementNotification和GKAchievementHandler类,同时进行相应更新和修改。首先,若你在游戏中运用ARC,快速扫描代码,移除那些发行、保留和自动发行代码属性。若你不想进行扫描,试着将文件放入项目及修复不符编译程序的内容,然后再创建内容。Type One Error类将展示类似于iOS 5所呈现的通知内容,但代码需获悉成就标题和描述是什么。为实现这点,你需要嵌入“showsCompletionBanner”目标。GKAchievementDescription目标的优点是它们已根据用户语言设定进行本土化,因此采用此方式不存在任何本土化问题。其弊端在于你无法只加载一个成就描述,你需要加载所有内容。我认为进行此操作的最佳时间是用户已在应用上认证Game Center,此时你需要通过异步调用获得这些消息。值得欣慰的是,苹果在此设有API调用,我将此放置在用户认证访问的CompletionHandler中。若你采用Ray Wenderlich网站的代码,那么你就既能够运用此方法,又拥有新方法。将NSMutableDictionary * self.achievementsDescDictionary添加至所有处理游戏Game Center代码的类(游戏邦注:它会在随后的体验中存储成就数据)。& &&- (void)authenticateLocalUser {
if (!gameCenterAvailable)
NSLog(@”Authenticating local user…”);
if ([GKLocalPlayer localPlayer].authenticated == NO) {
[[GKLocalPlayer localPlayer]
authenticateWithCompletionHandler:^(NSError *error) {
if([GKLocalPlayer localPlayer].isAuthenticated){
[self retrieveAchievmentMetadata];
//Here is the new code
//Here is the new method.
- (void) retrieveAchievmentMetadata
self.achievementsDescDictionary = [[NSMutableDictionary alloc] initWithCapacity:2];
[GKAchievementDescription loadAchievementDescriptionsWithCompletionHandler:
^(NSArray *descriptions, NSError *error) {
if (error != nil) {
NSLog(@&Error %@&, error);
if (descriptions != nil){
for (GKAchievementDescription* a in descriptions) {
[achievementsDescDictionary setObject: a forKey: a.identifier];
“retrieveAchievmentMetadata”方法会初始化所有信息库,然后调用游戏所有成就描述,进行循环,将它们添加至信息库。这属于异步调用,所以不应减缓游戏或项目的启动。
现在我们握有各成就的标题和描述,因此能够修改原始代码创造iOS 4/5的善意通知,其将通过Type One Error代码连续展示所有成就。
- (void)reportAchievement:(NSString *)identifier
percentComplete:(double)percentComplete {
GKAchievement* achievement = [[GKAchievement alloc]
initWithIdentifier:identifier];
achievement.percentComplete = percentC
if (percentComplete == 100.0) {
//Show banners manually
GKAchievementDescription *desc = [achievementsDescDictionary objectForKey:identifier]; //Update pull achievement description for dictionary
[[GKAchievementHandler defaultHandler] notifyAchievement:desc];
//Display to user
[achievementsToReport addObject:achievement];
//Queue up the achievement to be sent
[self save];
if (!gameCenterAvailable || !userAuthenticated)
[self sendAchievement:achievement];
//Try to send achievement
- (void)sendAchievement:(GKAchievement *)achievement {
[achievement reportAchievementWithCompletionHandler:
^(NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^(void)
if (error == NULL) {
NSLog(@&Successfully sent archievement!&);
[achievementsToReport removeObject:achievement];
//Remove Achievement from queue.
NSLog(@”Achievement failed to send… will try again \
Reason: %@”, error.localizedDescription);
}如果你想让成就中显示为你在itunes connect中设置成就的自定义图片,首先将通知部分代码修改成如下代码:if (percentComplete == 100.0) {
//Show banners manually
GKAchievementDescription *desc = [achievementsDescDictionary objectForKey:identifier];
[desc loadImageWithCompletionHandler:^(UIImage *image, NSError *error) {
if (error == nil)
[[GKAchievementHandler defaultHandler] setImage:desc.image];
//If image found, updates the image to the achievement image.
[[GKAchievementHandler defaultHandler] notifyAchievement:desc];
}使用以上方式默认为横屏显示成就通知,如果想换成竖屏提示,那么这里Himi给出参考代码:在“GKAchievementHandler”类中找到“notifyAchievement”,更新为:- (void)notifyAchievement:(GKAchievementDescription *)achievement
GKAchievementNotification *notification = [[GKAchievementNotification alloc] initWithAchievementDescription:achievement];
notification.frame = kGKAchievementFrameS
notification.handlerDelegate =
//Adjusting rotation.
if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft) {
notification.transform = CGAffineTransformRotate(notification.transform, degreesToRadian(-90));
notification.transform = CGAffineTransformRotate(notification.transform, degreesToRadian(90));
[_queue addObject:notification];
if ([_queue count] == 1)
[self displayNotification:notification];
}& & & ---------------游戏接入OpenFeint指南OpenFeint 是很多iPhone游戏开发者都要用到的社区功能;一、openfeint中的LeaderBoards 和Achievement的一点体会&&&&1.数据提交的格式&&&&最近想向自己 的游戏中添加点openfeint功能,使用的时候发现,openfeint的功能虽然比较多,也比较强大,但是,有些地方还是不太如人意。我游戏中的分 数有一项是float型的数据,可是当我提交的时候,发现openfeint的在线排名只支持整数形式的数据,改变了官方的api提交之后,服务器那边仍 自动转换成了整型的数据。我在论坛上求证了一下,虽然没有结论,但我认为openfeint高分排行榜仅支持整型的数据。&&&&2.数据提交的方法&&&&[OFHighScoreService setHighScore:你提交的分数&forLeaderboard:@&分数项的ID& onSuccess:OFDelegate() onFailure:OFDelegate()]; //提交高分,如果函数无效,请引入#import &OFHighScoreService.h&&&&&通过上面那个函数,就可以向服务器提 交数据,其中你要提交的分数,无论是什么类型,最后都会转换成整型的数据,可以参见上一条信息。而分数项ID,则是你在申请LaderBoards的时候 openfeint分配给你的一个数字。后面两个参数,应该不需要改变,我没有尝试过做其他的动作,有兴趣和想法的朋友,可以尝试象@selector那 样使用它。&&&&[OFAchievementService unlockAchievement: @&成就ID& onSuccess: OFDelegate() onFailure: OFDelegate()];//解锁成就,如果函数无效,请引入#import &OFAchievementService.h&&& 这个函数的功能是解锁成就,当你在游戏过程中达到某一个要求时,就可以解锁你在openfeint上预设的成就。&& 例如:&& 生存游戏中:if (生存时间 & 100s )&&{ 调用上面的函数解锁你自己预设的成就; }&& jump游戏中:if ( 高度 & 10000m )&&{ 调用上面的函数解锁你自己预设的成就; }&&&&3.网络对分数提交的影响&&&&网络畅通的情况下,调用上述函数提交分数(最高分数被刷新时) 可以成功,并且解锁成就并不会反复出现解锁提示。好吧,既然这个可以完成我们的要求,那么这里就不是重点。&&&&网络不通的情况下,就会出现一点问题:&&&&在阐明问 题之前,我想先说一下我对openfeint的数据存储的理解或者说感觉。使用penfeint的时候,在documents目录下会生成两个文件,一个 FakeKeyChain.plist,据我观察,这里面存放的就是我们在openfeint里为这个游戏申请的Product Key和Product Secret,而且Secret经过了加密处理。另一个文件则是feint-offline, 这个文件是无法打开的,在windows用记事本打开也是一堆乱码,也许有其他的办法,不过我没有找到。我对于这个文件的用途猜测是,这个文件用来存档玩 家的一些信息,比如玩家名和分数等,这个文件我暂时叫它为“本地隐 藏信息表”吧。&&&&&&&&问题来鸟,在没有网络的情况下,取得了一个分数,然后第一次调用分数提交函数,会提示你得 到了一个高分,存储在本地(我感觉就在本地隐藏信息表中), 问题出现了!当你这时连接网络,分数并不会自动提交,而你自己手动提交(比如点击一个按钮,按钮的功能是提交最高分数)也没有任何的效果。&&&&而 在官方文档中有这样一Q&A:&&&&Q:what happens to a high score when a player is offline?&&&&A:as os openfeint 2.1 high scoreare queued for submission when the player is offline and submitted when next he's online again.&&&&Q:if a user says no to using openfeint the first time,is there a way that user can change his or her mind to allow openfeint in the future?&&&&A:when you deny openfeint it will prompt you to approve/deny again when you open the dashboard([OpenFeint launchDashboard]).it will not prompt you on the next&app&bootup,or submitting any requests.only when you open the dashboard.&&&&也就是说,提交失败,于是我做了个试验,在有网络的情况下,提交一个分数100,只显示 一次,第二次提交100时,没有提示。然后提交101,有提示,第二次提交101,没有提示。说明了本地隐藏信息表中还存储了一个最高分数的提交次数和提交许可,使用一次提交分数的函数,这些内 容就会改变,只有新提交的分数比原来存储的分数大时,本地隐藏信息 表才会允许你向openfeint正式提交,否则,无效,感觉上和retain与release有点像。也就时说,最高的分数在提交的时 候,没有网络,就等于失败,这里应该算是openfeint的一个小bug吧。也是我遇到问题的所在,没找到什么解决办法,大伙有经验的可以提出来。&&&&用 个简单的图来形容下吧。&&&&无网络-&得到新高分-&存储在本地-&联网后-&不自动上传最高分。&&&&&&&&顺 便说下成就的提交,没有网络,不可解锁成就,也没有存在本地的提示,联网后,同样也不自动解锁,只有再一次达到条件(方才例子中的if成立)时,才会再次 解锁。&&&&以上,是我的部分openfeint基础使用的经验,也许是我的方法不正确,也许有别的解决办法,我能提供给大家的帮助, 先这么多了。二、 openfeint的设置(2.4.8版)&&&&以下步骤是假设你从没安装过openfeint,如果有,请将以 前老版本的openfeint从机器中删除,并从project中删除所有与openfeint有关的东西,然后,你可以按下面的步骤来做了。&&&&1. 从官网下载一个最新版本的没有解压的openfeint SDK。&&&&2.将openfeint文件夹拖入你的project中。&&&&3. 设置info&&&&&&&&&&&& a.打开project的info,选中build栏,将configuration设置成All configuration&&&&&&&& b.将Other Linker Flags一项的值设置成 -Objc&&区分大小写&&&&&&&& c.将Call C++ Default Ctors/Dtors in Objective-c项的选成yes(这一步我没有设置,不知道是什么意思,英文原文如下:Ensure 'Call C++ Default Ctors/Dtors in Objective-c' is checked under the 'GCC 4.2 - Code Generation' section)&&&&&&&& d.设置一个默认的值GCC_OBJC_CALL_CXX_CDTORS 为 YES(这一步我也没有设置)&&&&4.引入frameworks&&&&&&&& 需要引入的frameworks 有,Foundation,UIKit,CoreGraphics,QuartCore,Security,SystemConfiguration,libsql3.0 dylie,libz.1.2.3.dylib这些是官方给出需要引入的frameworks,根据帮我搭建工程的前辈说,必须要引入 CoreLocation.framework&&&&CFNetwork.framework&& MapKit.framework&&&&&& 5.必须在你的&& .pch&& 文件中引入#import “OpenFeintPrefix.pch”&&&& 6.将你所有使用openfeint功能的函数改为&&.mm&&文件&&&& 我能想到的就这些了,还有什么问题,大家可以互相讨论。三、openfeint的注册&&&&openfeint的注册并不难,能看懂 文档的水平基本就可以了,也可以配合翻译软件来弄。&&&&1.打开官网&&&&&&2.选右上角的 Developers一项,跳转到的新界面。&&&&3.点击本页面的右上角的login会进入登陆界面,选择右上角的 sign up进行一个简单注册,本页右下角有一个教学的视频,告诉你如何使用openfeint的基础功能。&&&&4.简单注册界面,填写完成后跳转到一个新的界面,点击Dive in 进入你自己的openfeint里。&&&&5.进入自己的openfeint了,需要进行一个prepare for submission的申请,这个可以让你的openfeint有效,否则,你只能使用test user 进行测试。在App Home中,可以看到自己的client Id 这个是用来提问用的,以及最重要的Product Key和Product Secret,这两项是用来识别你的程序独有的openfeint的。&&&&6.还需要一个你注册时使用的邮箱认证。进入自己的邮箱就能看到 了。&&&&7.想通过openfeint的审核,还需要完善一个ipurchase的填写,在basic features/iPurchase里面填写,*项必须要有内容。&&&&8.完成上面这些,你就可以设置自己的LaderBoards和 Achievement了,还有更多的challenge等。& & && & & & & & & & & & & & & & & & &------以上为Himi的经验总结以及参考资料,希望对大家有帮助;
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:1681828次
积分:15324分
排名:第185名
原创:147篇
评论:2774条
移动开发专家,专注于移动开发领域,多年 J2me、Android、iOS 平台游戏开发经验;
CSDN、ITeye、51CTO、eoe-Android、泰然、中国移动开发者社区、微度网等多家技术论坛担任专家与版主;
? 【iOS】(高级群/超级群)
Cocos2d-x @Himi:
? 【Lua】(高级群)
Cocos2d-x-Lua @Himi:
? 【Unity3D】(超级群)
Unity3D @Himi:
文章:62篇
阅读:783219
文章:34篇
阅读:568338

我要回帖

更多关于 幻想神域国服圣剑 的文章

 

随机推荐