解锁成就 - GameCenter iPhone
我正在尝试解锁我为 iPhone 制作的游戏中的一项成就,但相当不成功。
从 Apple 自己的 GKTapper 项目示例(演示 Game Center 代码)中,我已将 GameCenterManager.h 和 .m 以及 AppSpecificValues.h 文件复制到我的项目中。我已成功加载成就和排行榜以供查看。
然而,我无法弄清楚或正确地了解如何真正解锁成就。有人可以指出如何使用这个或不使用 GameCenterManager 如何解锁成就吗?
谢谢。
I am trying to unlock an achievement in the game i am making for the iPhone but being rather unsuccessful.
From Apples own GKTapper project sample demonstrating Game Center code I have copied the GameCenterManager.h and .m and the AppSpecificValues.h files into my project. I have successfully got loading the achievements and leaderboards for viewing.
However I can't work out or get right how to actually unlock an achievement. Could some point out how using this or without the GameCenterManager how can I unlock an achievement please?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样调用这个方法:
如果你只想解锁成就,请这样调用:
你可以使用浮点来计算成就的百分比,如果用户达到 100,成就就会解锁。
您也可以这样做:
neededPoints 表示解锁该成就所需的积分。例如:
实际积分 = 300;
需要积分 = 600;
计算结果:300/600 = 0.5 * 100 = 50%
Call this method like this:
If you want to just unlock the achievement call this:
You can use the float for calculate the percent of the achievement, and if the user reaches the 100 the achievement gets unlocked.
You can also do this:
neededPoints means the points you need for unlock this achievement. For example:
actualPoints = 300;
neededPoints = 600;
It calculates: 300/600 = 0.5 * 100 = 50%
顺便说一句,如果您设置percentComplete=100,则“completed”属性并不总是设置为YES,至少不在同一会话中。我花了一段时间来调试为什么我的游戏多次授予成就,即使百分比已设置为 100。
Btw, the "completed" property isn't always set to YES if you set percentComplete=100, at least not within the same session. I spent a while debugging why my game awarded achievements several times even when percentComplete got set to 100.