Game Center Techniques, Part 1

Similar documents
Integrating Game Center into a BuzzTouch 1.5 app

App Publishing with itunes Connect

Cross Platform Nearby Networking

Introducing the Photos Frameworks

Kevin van Vechten Core OS

Mastering Xcode for iphone OS Development Part 2. Marc Verstaen Sr. Manager, iphone Tools

GKPlayer object, 59 NSMutableArray, 60 playernameforid, 62 posting a score, 64 presentation Apple s GUI, 49 custom GUI, 53 in social app or game, 36

Mastering Xcode for iphone OS Development Part 1. Todd Fernandez Sr. Manager, IDEs

Editing Media with AV Foundation

Creating Great App Previews

Address Book for iphone

Introduction to Amazon Lumberyard and GameLift

Accessibility on ios. Developing for everyone. Frameworks #WWDC14. Session 210 Clare Kasemset ios Accessibility

Accessibility on OS X

Building Watch Apps #WWDC15. Featured. Session 108. Neil Desai watchos Engineer

ios in Practice MANNING BEAR CAHILL Shelter Island

What s New in tvos #WWDC16. App Frameworks. Session 206. Hans Kim tvos Engineer

Xerox Mobile Client for DocuShare User Guide

Power, Performance, and Diagnostics

Fundamentals of Programming Session 12

What s New in Xcode App Signing

Creating Extensions for Safari

Intro to Native ios Development. Dave Koziol Arbormoon Software, Inc.

Media and Gaming Accessibility

CS193P - Lecture 3. iphone Application Development. Custom Classes Object Lifecycle Autorelease Properties

Grand Central Dispatch and NSOperation. CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015

Mary Kay Social Publisher. Sales Force Tutorial

icontact for Salesforce Installation Guide

Stanford CS193p. Developing Applications for ios. Spring Stanford CS193p. Spring 2012

Creating Content with iad JS

If you re a Facebook marketer, you re likely always looking for ways to

CS193p Spring 2010 Wednesday, March 31, 2010

Using and Extending the Xcode Source Editor

Technology Terms for 2017

2018 Educare Learning Network Meeting App Instructional Guide

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010

Introducing CloudKit. A how-to guide for icloud for your Apps. Frameworks #WWDC14. Session 208 Olivier Bonnet CloudKit Client Software

Version 1.4 Published on 1st July, 2017

Frequently Asked Questions About Columbia Connect

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions

Procedures, Parameters, Values and Variables. Steven R. Bagley

Data IAP 2010 iphonedev.csail.mit.edu edward benson / Thursday, January 14, 2010

Hi this is Anna Jarrett, I am here to present today s Digital Cookie online training.

Introducing On Demand Resources

Vodafone One Net app Quick Start Guide For iphone

CloudKit Tips And Tricks

Seamless Linking to Your App

Data Delivery with Drag and Drop

Heuristic Evaluation of [Slaptitude]

Design Phase. Create a class Person. Determine the superclass. NSObject (in this case)

Using HTML5 Offline Storage. Brady Eidson Safari and WebKit Engineer

What s New in the LLVM Compiler. Chris Lattner LLVM Chief Architect

From the main page click the Create Account button.

Vodafone One Net app Quick Start Guide For iphone

Introducing the Modern WebKit API

ios: Objective-C Primer

Assignment II: Foundation Calculator

ITP 342 Mobile App Development. Data Persistence

Vodafone One Net app Quick Start Guide For Android phone

itunes Connect Development to distribution #WWDC15 Distribution Session 304

Monetize and Promote Your App with iad

CareCarma. It Starts With Family

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011

Online & Mobile Banking Pilot

Working with Metal Overview

Onboarding Guide. ipointsolutions.net (800)

Getting Around. Welcome Quest. My Fundraising Tools

Announcement. Final Project Proposal Presentations and Updates

WEST TEXAS A&M UNIVERSITY

ENROLLING FOR YOUR SYKES HOME TRAINING

iphone Application Programming Networking

WiiConnect24. Martin Buchholz Developer Relations & Support Nintendo of Europe Software Development Support Group

Finding Bugs Using Xcode Runtime Tools

User Guide. Admin Guide. r

Beating the Final Boss: Launch your game!

Functions. Computer System and programming in C Prentice Hall, Inc. All rights reserved.

Localizing with Xcode 6

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

Getting Started with our Updated Web Site

Jazz for Justice Pensacola Ambassador of Justice Fundraising Page

Connecting to Telegram

Cisco Events Mobile Application

Reviewer Reviewer Guid Guide e Last Las t update update Nov Nov

Review Chapter 6 in Bravaco. Short Answers 1. This type of method does not return a value. a. null b. void c. empty d. anonymous

Kenneth Dyke Sr. Engineer, Graphics and Compute Architecture

CS193P - Lecture 13. iphone Application Development. Address Book - Putting People in Your App

Cisco StadiumVision Mobile API for Apple ios

The Three Attributes of an Identifier

ITP 342 Mobile App Dev. Unit Testing

Working Effectively with Objective-C on iphone OS. Blaine Garst Wizard of Runtimes

ios Application Development Course Details

Review: C Strings. A string in C is just an array of characters. Lecture #4 C Strings, Arrays, & Malloc

Please note: This procedure is exactly the same for the emwave2 program as well as the emwave PRO.

Running Effective Projects In Office 365. June 1, 2017

Yada. A blockchain-based social graph

AmbirScan User Guide Ambir Technology, Inc. Page 1 of 8 UG-AS-5.0

Fix Bugs Faster Using Activity Tracing

Windows 10 Tips & Tricks

Your Apps and the Future of macos Security

New UIKit Support for International User Interfaces

Transcription:

Game Center Techniques, Part 1 Get Your Game On Gabriel Belinsky Senior Software Engineer 2

Game Center Friends Leaderboards Achievements Multiplayer gaming 3

What You ll Learn Game Center API basics Authenticate with Game Center Remember players across different play sessions Report a high score Access and show a Leaderboard in game Report an achievement Access and show achievements in game Reset user s achievements 4

Game Center Overview Game Center App Your Game GameKit Game Center Only Account Management General Authentication Multiplayer Auto-Matching Game Center Services Friends Management Friends Invitations Multiple Games Leaderboards Peer-to-Peer Networking Achievements In-Game Voice Chat Other Frameworks (UIKit, OpenGL, etc.) 5

General Services Authentication Friends Leaderboards Achievements 6

Blocks-Based API Definition of blocks main() { int x = 123; int y = 456; Captures Enclosing Variables void (^myblock)(int) = ^(int z) { printf( %d %d %d\n, x, y, z); } Anonymous function Blocks can be declared like any C variable } myblock(789); Outputs 123 456 789 7

Blocks-Based API API usage [gamekitobject doactionwithcompletionhandler:^(id result, NSError *error) { if (result) { // process the result } if (error) { // process the error } }]; 8

GameKit Errors GKError.h GKErrorCancelled GKErrorCommunicationsFailure GKErrorInvalidCredentials GKErrorNotAuthenticated GKErrorAuthenticationInProgress GKErrorScoreNotSet GKErrorParentalControlsBlocked GKErrorMatchRequestInvalid 9

General Services Authentication Friends Leaderboards Achievements 10

GKLocalPlayer Represents current player on the device Holds current player info playerid alias underage Performs authentication Access friends list 11

GKLocalPlayer Authentication Required to use the rest of Game Center GKLocalPlayer* localplayer = [GKLocalPlayer localplayer]; [localplayer authenticatewithcompletionhandler:^(nserror *error) { if (!error) { self.gamecenterfeaturesenabled = YES; } else { self.gamecenterfeaturesenabled = NO; } }]; 12

Authentication Screenshots 13

General Services Authentication Friends Leaderboards Achievements 14

GKPlayer Properties playerid Persistent identifier Keep track of players over time Associate data with players alias Display name for player 15

Friends Getting friends list GKLocalPlayer* localplayer = [GKLocalPlayer localplayer]; [localplayer loadfriendswithcompletionhandler:^(nsarray *friends, NSError *error) { if (friends) { // friends array contains a GKPlayer for each friend of localplayer } if (error) { // handle error } }]; 16

What to Do with the Friends List Attach custom data to players on your own server Extend Game Center functionalities Virtual goods Cross-session messaging Use the social graph as part of your gameplay Let your users visit each other s virtual places Use the connections to enhance their virtual character 17

General Services Authentication Friends Leaderboards Achievements 18

Leaderboard Concepts A list of high scores earned in a game Filters for friends and time Can be broken out by category Optional global Leaderboard 19

Leaderboard Steps Server-side setup Report a score Show Leaderboard to user Query Leaderboard data 20

Leaderboard Server-side setup Done in itunes Connect Enable Leaderboard for your game Set up your Leaderboard Leaderboard identifier Sort order Add languages Score format Optional score format suffix More languages = more sales 21

22

Leaderboard Formatting Example Submitted Value Selected Formatter Formatted Value 123456 Integer (214,000,529) 123,456 792 Elapsed Time (hours, minutes) 13:12 3723 Elapsed Time (hours, minutes, seconds) 1:02:03 1042 Money ($10,000,012) $1,042 23

Reporting a Score Allocate a GKScore Set value Set category if using multiple Leaderboards Report score Developer responsible for retry on network errors 24

GKScore Properties value formattedvalue category date player rank 25

Reporting a Score GKScore* myplayerscore = [[[GKScore alloc] init] autorelease]; myplayerscore.value = 12345; [myplayerscore reportscorewithcompletionhandler:^(nserror *error) { if (error) { NSData* archivedscore = [NSKeyedArchiver archiveddatawithrootobject:myplayerscore]; [self savescoretosendlater:archivedscore]; } else { // the score was submitted successfully } }]; 26

Leaderboard Standard UI - (void)showleaderboard { GKLeaderboardViewController* myleaderboardviewcontroller = [[[GKLeaderboardViewController alloc] initwithtimescope:gkleaderboardtimescopeweek playerscope:gkleaderboardplayerscopefriendsonly ] autorelease]; [myleaderboardviewcontroller setleaderboarddelegate: self]; } [self presentmodalviewcontroller: myleaderboardviewcontroller];; - (void)leaderboarddidpressdismiss { [self dismissmodalviewcontrolleranimated:no]; } 27

Querying a Leaderboard Allocate a GKLeaderboard Set time scope (today/week/all time) Set player scope (friends/everyone) Set range of ranks desired Set category if using multiple leaderboards Returns an NSArray of GKScores which contain the following properties: player (a GKPlayer object) rank value formattedvalue date 28

Querying a Leaderboard GKLeaderboard* myleaderboard = [[[GKLeaderboard alloc] init] autorelease]; // interested in friends scores over the past week myleaderboard.timescope = GKLeaderboardTimeScopeWeek; myleaderboard.playerscope = GKLeaderboardPlayerScopeFriendsOnly; myleaderboard.range = NSMakeRange(1,25); [myleaderboard loadscoreswithcompletionhandler:^(nsarray *scores, NSError *error) { if (scores) { //scores now contains all the scores received per the query for (GKScore *score in scores) { // looping through all the scores in the array // display in custom UI } } if (error) { // handle error } }]; 29

Leaderboard Screenshots 30

General Services Authentication Friends Leaderboards Achievements 31

Achievements Concepts Something of significance that is accomplished by a player Completed a level within 60 seconds Looted all the treasure in the dungeon Checking out our labs tomorrow Increases player engagement in your game Encourages online and offline competition 32

Achievements Steps Server-side setup Reporting achievements Getting achievement descriptions Querying achievements Show achievements to user Standard UI Custom UI Resetting achievements list 33

Achievements Server-side setup Done with itunes Connect Enable achievements for your game in itunes Connect For each achievement: Enter the achievement ID (must be unique, inverse DNS is perfect) Enter the achievement title Enter the description before the user achieves it Enter the description after the user achieves it Enter a point value Select the hidden flag if you do not want the user see that achievement before you unhide it Upload the icon you want to attach to this achievement 34

Achievements GKAchievementDescription This is the list of achievements for your game Unique ID Title Icon Description if not achieved Description if achieved Points Flag to hide the achievement 35

Achievements GKAchievement This is the list of achievements attached to GKLocalPlayer Unique ID Percentage completed Hidden flag Completed flag Date of report Points 36

Reporting an Achievement Allocate a GKAchievement for the achievement ID Set percent complete Developer is responsible for retry on network errors 37

Reporting an Achievement GKAchievement* myachievement = [[[GKAchievement alloc] initwithidentifier:@ com.mycompany.mygame.achievementx ] autorelease]; myachievement.percentcomplete = 50.0; [myachievement reportachievementwithcompletionhandler:^(nserror *error) { if (error) { NSData* archivedachievement = [NSKeyedArchiver archiveddatawithrootobject:myachievement]; [self saveachievementtosendlater:archivedachievement]; } else { // the achievement was submitted successfully // Note: reporting an achievement will unhide it } }]; 38

Achievements Standard UI Implement GKAchievementViewControllerDelegate - (void)showachievements { GKAchievementViewController* myachievementsviewcontroller = [[[GKAchievementViewController alloc] init] autorelease]; [myachievementsviewcontroller setachievementviewcontrollerdelegate: self]; } [self presentmodalviewcontroller:myachievementsviewcontroller]; - (void)achievementsdidpressdismiss { [self dismissmodalviewcontrolleranimated:yes]; } 39

Getting Achievements Descriptions @property (retain) NSMutableDictionary *achievementdescriptiontable; [GKAchievementDescription loadachievementdescriptionswithcompletionhandler: ^(NArray *descriptions, NSError *error) { if (descriptions) { for (GKAchievementDescription *description in descriptions) { [self.achievementdescriptiontable setobject:description forkey:description.identifier]; } } if (error) { // handle error } }]; 40

Querying Achievements @property (retain) NSMutableDictionary *achievementdescriptiontable; - (void)logachievements { [GKAchievement loadachievementswithcompletionhandler: ^(NSArray *achievements, NSError *error) { } if (achievements) { for (GKAchievement *achievement in achievements) { GKAchievementDescription *description; description = [self.achievementdescriptiontable objectforkey:achievement.identifier]; NSLog(@ achievement: %d/%d - %@, achievement.points, description.maximumpoints, description.title); } } if (error) { // handle error } }]; 41

Resetting User s Achievements [GKAchievement resetachievementswithcompletionhandler:^(nserror *error) { }]; if (error) { // Achievements list was not reset. Process error } else { // the user s achievements list was reset } 42

Achievements Screenshot 43

Summary Game Center is a blocks-based API Asynchronous blocks API You must authenticate before doing anything else Report a high score Access and show a Leaderboard in game Report an achievement Access and show achievements in game Reset a user s achievements Achievements will be available later this year 44

More Information Allan Schaffer Graphics and Game Technology Evangelist ashaffer@apple.com Documentation iphone Dev Center http://developer.apple.com/iphone 45

Related Sessions Introduction to Game Center Game Center Techniques, Part 2 Pacific Heights Tuesday 2:00PM Marina Tuesday 4:30PM What s New in Foundation for ios 4 Introducing Blocks and Grand Central Dispatch on iphone Pacific Heights Tuesday 10:15AM Russian Hill Wednesday 11:30PM For more on blocks go to Apple Developer Connection at: http://developer.apple.com 46

Labs Game Center Lab Game Center Lab Lab B Wednesday 2:00PM Lab D Friday 12:45PM 47

Q&A 48

49

50