原地址:http://blog.sina.com.cn/s/blog_6b3661a901013xb0.html

This is the first part of a step-by-step tutorial on how to use Game Center in your app. Game Center is supported since iOS 4.1. It’s Apple’s new social network. Game Center enables users to track their best score on a leaderboard, compare their achievements, invite friends to play a game, and start a game through auto-matching. This tutorial is only useful if you are a paid developer, because if you are not, you can’t setup the Game Center achievements and leaderboard in iTunes Connect. In the firts part we will create our project and create a new app in iTunes Connect with achievements and a leaderboard for this tutorial

Step 1: Creating the Project

Open Xcode and select “Create a new Xcode project”. Select a View-based Application and click Next. Enter a name for your project, I called mine “Game Center”. Enter your Company Identifier and make sure you select iPhone for Device Family, because we are going to make an iPhone app. If you are done, click next. Choose a place to save your project and click create.

Step 2: Import the GameKit Framework

In the navigator area of Xcode 4, select the project name (in this case “Game Center”). Next, select the current target (“Game Center” here again), and then select the “Build Phases” tab. Expand the “Link Binary With Libraries” option, and then click the “+” button to add a new framework. Type “game″ into the search box, and select the GameKit.framework framework that appears in the list. Click “Add” to include this framework in the linking phase of your project.

Step 3: Creating the App ID

To do this, you have to be a paid developer. To use Game Center you need to add a new app and to that you need an App ID. Open up Safari or another web browser you prefer. Go to the iOS Dev Center and Log in to your iOS Developer account.

If you are logged in, you see a button to go to the iOS Provisioning portal. Click that button and go to “App ID’s”. Because we want to create a new app ID, click “New App ID”. As description I choose “Game Center App ID” so I know that this app ID is for my Game Center app. We don’t want to make a suite of applications that share the same keychain access, so we leave the Bundle Seed ID to “Generate New”. The recommended usage for a Bundle Identifier is com.domainname.applicationname. As domainname I chose my own name, Jeroen van Rijn. I called my application “Game Center” so my Bundle Identifier is “com.jeroenvanrijn.gamecenter” (without the quotes). Click “submit” to finish the App ID.

Step 4: Adding a New App

Go back to the iOS Dev Center and go to iTunes Connect by clicking the button that says “iTunes Connect” or go directly to iTunes Connect. Go to “Manage Your Applications”, here we will create a new app, that we will use for our Game Center example. Because I’ve one app in the App Store, this window may look some different. Click “Add New App” to start creating or new app.

If this is your first app you will need to enter some information, but that is pretty straight forward. If you entered that information, you need to enter an App name, a SKU number and a Bundle ID. The App name is of course the name of your app. The SKU Number is a unique number to identify the app you are adding. For the Bundle ID you need to choose the App ID you just created in the iOS Provisioning Portal. If you are done, click “Continue”.

In the next window we will enter an availability date and the price of the app. I chose just a random date, because I’m not going to submit the app in the App Store. As Price Tier I chose “Free”, you can chose whatever you want. I deselected the “Discount for Educational Institutions”. This means that educational institutions can’t buy your app once and install it on different devices. If you are done, click “Continue”.

In the third window we will enter our Version information. My screen says that I need to enter the following in Dutch, but yours will say the language you chose for your first application. The Metadata and rating are pretty straight forward. For the Images you need to choose an icon and an iPhone / iPod touch Screenshot. The iPad Screenshot is optional. You can choose your own images or use mine.

If you are done, click “Save”.

Congratulations, you have created a new app in iTunes Connect.

Step 5: Creating a Leaderboard

Now go to “Manage Game Center”, here we will enable our app for Game Center and later create a leaderboard and some achievements.

Click “Enable”, after you clicked, the button on your screen will chance and you can setup a leaderboard and achievements. First we will setup a leaderboard. In the “Leaderboards” section, click “Set up” and in the next window click “Add Leaderboard”.

We want to create a single leaderboard, so under “Single Leaderboard” click “Choose”.

 

In this window, we will enter our leaderboard information. The “Leaderboard Reference Name” is an internal name that you must provide for each leaderboard. I Named mine “Game Center Test Leaderboard”. The “Leaderboard ID” is a unique alphanumeric identifier that you create for this leaderboard. I chose “1”, because this will be the first leaderboard for this app. We will use this leaderboard ID later in Xcode to identity our leaderboard. The “score Format Type” is the type of format in which the score for your app will be expressed on the leaderboard in Game Center. Choose “Integer” as format type. For “Sort Order” choose “Descending”. This means that the highest score will be displayed first. If you want the lowest score to be displayed first, choose “Ascending”

There is still one thing left to do for finishing our leaderboard, and that is adding a language, so click “Add Language”.

For “Language” I chose “English” Feel free to choose a language you prefer. The “Name”, is the name of the leaderboard displayed in Game Center. I named mine “Leaderboard”. The “score Format” is the format which will displayed on your leaderboard for each specified language. I chose “Integer (100.000.122)” The “Score Format Suffix (Singular)” and “Score Format Suffix (Plural) are optional. The score format suffix will be added to the end of scores displayed on your leaderboard. You can use this for clarifying the type of score your app uses. When you are done entering the language information, click “Save”. Feel free to add more languages, but I leave it at one for this tutorial. To finish the leaderboard click “Save”.

Now, we have created a Game Center leaderboard. As you can see, this leaderboard is selected as the default leaderboard, because it’s the only leaderboard we have for this app. Click “Go Back”, so we can add some achievements.

Step 6: Creating the Achievements

Now we are going to create the achievements. For this tutorial I am going to make 2 achievements. In the “Achievements” section click “Set up”. In the next window click “Add New Achievement”, to create the first achievement for this tutorial.

The “Achievement Reference Name” and “Achievement ID” are the same as the ones for the leaderboard, we just created. As “Achievement Reference Name” I chose “1 Tap” and as “Achievement ID” I chose “1_tap”. For “Hidden” I chose “No”, because we don’t want that a achievement will remain hidden on Game Center until a player has achieved it. “Point Value” means the points that your achievement is worth. I chose 10 for this achievement. There is a maximum of 100 points per achievement and a maximum of 1000 point total for all achievements. Again we have to add a language. Click “Add language”. For “Language” I chose “English” again and for “Title”, “1 Tap”. The “Pre-earned Description” is the description of your achievement before they have earned it. I chose “Tap Once”, because that is what they need to do to earn this achievement. The “Earned Description” is of course the description of your achievement when they have earned it. I chose “You tapped the button”. You must provide a 512×512 pixels image. If you click the question mark at “Image” you can see the supported formats. You can choose your own image or use mine.

If you are done, click “Save”. You can add more languages, but I leave it at one. Click “Save” to finish this achievement.

In the next window you can add a new achievement. Click “Add New Achievement. This time I entered the following information:

  • Achievement Reference Name: 20 Taps
  • Achievement ID: 20_Taps
  • Hidden: No
  • Point Value: 50

Click “Add Language” to enter a language. This time I entered the following information:

  • Language: English
  • Title: 20 Taps
  • Pre-earned Description: Tap 20 Times
  • Earned Description: You tapped the button 20 times
  • Image: (the same as the first achievement)

If you are done, click “Save”. Click “Save” again to finish the second, and last achievement for this tutorial.

Step 7: Enabling Game Center

Click “Go Back” and in the next window click “Done”. In the “Versions” click “View Details”. In the next window scroll down to the “Game Center” section.

Click “Enable for This Version”. The “Game Center” section should change in this one:

Now we are done in iTunes Connect. You can close your browser and go back to the Game Center project in Xcode we created at the beginning of this tutorial.

Step 8: Download GKTapper

We will use some files from the GKTapper Sample Code from Apple. You can download the GKTapper Sample Code here.
When the download completed, open the project and drag the following files to the “Project Navigator” in our Game Center project:

  • GameCenterManager.h
  • GameCenterManager.m
  • AppSpecificValues.h

Make sure “Copy Items into destination group’s folder (if needed) is checked, and click “Add”. Now you can close the GKTapper project. You can also delete it, if you want, because we won’t need it anymore for this tutorial. We use those files, because the GameCenterManger classes will do the heavy lifting for us.

Step 9: Change the Bundle identifier

In your Xcode project, open the Game-Ceter-Info.plist file from the “Supporting Files” folder in the “Project Navigator”. Fill in the “Bundle Identifier” value with the one created earlier and associated with the App ID. I named my Bundle Identifier “com.jeroenvanrijn.gamecenter”.

Conclusion

In this part of the tutorial we have covered how to create a new app with achievement and a leaderboard in iTunes Connect. In the second part we will finish the tutorial, so we can use the leaderboard and achievements.

Game Center Achievements and Leaderboards part 1 <转>的更多相关文章

  1. Unity 3D学习之 Prime31 Game Center插件用法

    http://momowing.diandian.com/post/2012-11-08/40041806328 It's my life~: 为app 连入Game Center 功能而困扰的朋友们 ...

  2. easyUI 如何不跳转页面,只是加载替换center部分内容

    以前做的一个故障报修系统,前端框架使用easyUI框架,layout布局,center使用datagrid .点击左边树形菜单时时页面跳转,想要知道如何点击菜单时不进行页面跳转,而是只对center模 ...

  3. text-align=center 失效原因

    text-align属性是针对 内联元素居中得属性设置,对于块状元素使用margin:0 auto;来控制居中: 笔者在设置一个h2标签时设置了text-align:center;但是却始终出现在中间 ...

  4. Thinkstation center M8600t装RHEL7不能联网,网卡驱动没装问题

    Thinkstation center M8600t装RHEL7时不能联网,配置ip也不可以,后来发现网卡驱动没有安装.可以通过装网卡驱动的方式解决问题,解决方法如下: root登录 lspci |  ...

  5. Radmin Center 1.54 测试版

    软件简介:radmin center 用于集中管理安装了 radmin server 的服务器,支持一键远程管理,数据全部本地存储,关键数据使用RC4变形加密.同时保留了radmin的高安全性和高易用 ...

  6. margin:0 auto 与 text-align:center

    1.text-align:通过指定行框与哪个点对齐,从而设置块级元素内文本的水平对齐方式;            text-align:center 设置文本或img标签等一些内联对象的居中. 2.m ...

  7. margin:0 auto 与 text-align:center 的区别

    基本概念: 1.text-align: 属性规定元素中的文本的水平对齐方式;   该属性通过指定行框与哪个点对齐,从而设置块级元素内文本的水平对齐方式;  一般情况下设置文本对齐方式的时使用此属性.支 ...

  8. [XAF] How to set List View Columns Title Customization align center?

    https://www.devexpress.com/Support/Center/Question/Details/T423138

  9. iOS--------坐标系统(UIView的frame、bounds跟center属性)

    1.概要翻开ios官方开发文档,赫然发现上面对这三个属性的解释如下: frame:描述当前视图在其父视图中的位置和大小. bounds:描述当前视图在其自身坐标系统中的位置和大小. center:描述 ...

随机推荐

  1. Java实现蛇形矩阵

    public class Solution { //下x++ 左y-- 上x-- 右y++ public void prints(int n) { int[][] mp = new int[n][n] ...

  2. LibreOJ #139 树链剖分 [树链剖分,线段树]

    题目传送门 树链剖分 题目描述 这是一道模板题. 给定一棵 n 个节点的树,初始时该树的根为 1 号节点,每个节点有一个给定的权值.下面依次进行 m 个操作,操作分为如下五种类型: 换根:将一个指定的 ...

  3. J2EE技术架构

    一.简介 J2EE(Java 2 Platform, Enterprise Edition)是一个为大企业主机级的计算类型而设计的Java平台.Sun微系统(与其工业伙伴一起,例如IBM)设计了J2E ...

  4. python搜索引擎(转)

    用python如何实现一个站内搜索引擎? 先想想搜索引擎的工作流程: 1.网页搜集.用深度或者广度优先的方法搜索某个网站,保存下所有的网页,对于网页的维护采用定期搜集和增量搜集的方式. 2.建立索引库 ...

  5. Gym 101128F Sheldon Numbers(网络流)

    [题目链接] http://codeforces.com/gym/101128/attachments [题目大意] 给出一张地图,分为高地和低地,高低地的交界线上划有红线, 现在要开小车跨过每条红线 ...

  6. 【构造】【分类讨论】Codeforces Round #435 (Div. 2) C. Mahmoud and Ehab and the xor

    题意:给你n,x,均不超过10^5,让你构造一个无重复元素的n个元素的非负整数集合(每个元素不超过10^6),使得它们的Xor和恰好为x. 如果x不为0: 随便在x里面找一个非零位,然后固定该位为0, ...

  7. 【构造】【贪心】hdu6090 Rikka with Graph

    给你n个点,让你连m条边,使得任意两两点对之间的最短路的和最小(两点若不可达,最短路记作n). 初始时ans=n*n*(n-1). 先尽量连成菊花图,每连一次让答案减小2*((n-2)*(i-1)+( ...

  8. 【set】【链表】hdu6058 Kanade's sum

    f(l,r,K)表示区间l,r里面的K大值,问你所有连续子区间的f之和. l(i)表示i左侧第一个比它大的数的位置,r(i)表示i右侧第一个比它大的数的位置.可以用set处理出来. 把数从大到小排序, ...

  9. 【动态规划】【二分】CDOJ1006 最长上升子序列

    最长上升子序列. 要求输出字典序最小解. 就在更新答案的时候记录一下前驱.容易发现记录的这个玩意实际上形成了一个森林. #include<cstdio> #include<algor ...

  10. Problem F: 零起点学算法101——统计字母数字等个数

    #include<stdio.h> #include<string.h> int main(){ ]; while(gets(str)!=NULL){ ,b=,c=,d=; ; ...