SlideShare una empresa de Scribd logo
1 de 35
Integrando Game Center
         en iOS
       Pablo Ezequiel Romero
    http://about.me/pabloromero
Agenda
Que es Game Center?

Características

Configuración / integración

Repaso features mas importantes

iOS 5

Ventajas / limitaciones

Temas mas avanzados

Para seguir leyendo
Que es Game Center?

Una iOS app

Un conjunto de
servicios

Un API
Que funcionalidad
      provee?

Autenticación     Matchmaking

Lista de Amigos   Peer-to-peer

Leaderboards      Voice chat

Achievements
Características de Game
         Center
 Es parte de GameKit (disponible desde iOS
 3.0)

 >= iOS 4.1, no compatible con iPhone 3g ni
 iPod 1ra generación

 Algunas cosas no se puede probar en el
 simulador

 Entornos: sandbox / producción
Características del API
Posts y requests

Estandar UI vs custom

Funciones asicrónicas

Blocks

Si un post falla es tu responsabilidad

Infomación cacheada
Manos a la obra!
1. Crear la app en iTunes Connect

2. Habilitar Game Center

3. Setear el Bundle ID en nuestra app

4. Agregar GameKit.framework

5. Import <GameKit/GameKit.h>

6. Opcional o no
Autenticación
Lo antes posible

playerID: único, el mismo en distintos dispositivos

Atributos propios

Tres escenarios:

  Usuario ya logueado

  Usuario no logueado,
  pero ya registrado

  Usuario no logueado,
  sin registrar
Autenticación

GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];

[localPlayer authenticateWithCompletionHandler:^(NSError *error) {

      if (error) {
           // Error
      }

}];
Lista de amigos
Obtener una lista de playerIDs

Obtener una lista de GKPlayers

Incorporar servicios no soportados por GC:

  Atributos propios

  Enviar gifts

  Enviar mensajes

Las amistades se crean desde Game Center app.

GKFriendRequestComposeViewController (iOS 4.2 )
Lista de amigos
  Lista playerIDs
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
[localPlayer loadFriendsWithCompletionHandler:^(NSArray *identifiers, NSError *error) {

      if (identifiers) {
           // Array de player identifiers, puede ser info cacheada
      }
      if (error) {

      }
}];
  Lista GKPlayers
[GKPlayer loadPlayersForIdentifiers:identifiers WithCompletionHandler:^(NSArray *friends,
NSError *error) {

      if (friends) {
           // Array de GKPlayer
      }
      if (error) {

      }
}];
Leaderboards
De todos los gustos y colores

Se configura desde iTunes
connect, muy simple (es un ABM)

  Id, orden, tipo (entero, dinero,
  decimal, tiempo)

  Localizable (nombre, imagen,
  sufijo, formato)

Máximo de 25

Default

Estandar UI o custom
Leaderboards -
          Reportando un score
GKScore *score = [[[GKScore alloc] initWithCategory:@"identifier"]
autorelease];

score.value = 100;

[score reportScoreWithCompletionHandler:^(NSError *error){

      if (error) {
              // Salvar o no? GKScore soporta NSCoding
      } else {

      }

}];
Leaderboards - Listando
                   scores
GKLeaderboard *leaderboard = [[[GKLeaderboard alloc] initWithCategory:@”identifier”]
autorelease];

leaderboard.timeScope = GKLeaderboardTimeScopeWeek;
leaderboard.friendScope = GKLeaderboardPlayerScopeFriendsOnly;
leaderboard.range = NSMakeRange(1,25);

[leaderboard
 loadScoresWithCompletionHandler:^(NSArray *scores, NSError *error) {

      if (scores) {
           // Array de GKScore, puede ser info cacheada
      }

      if (error) {

      }

}];
Achievements
Se configura desde iTunes connect,
tambien muy simple

  Id, oculto

  Localizable (nombre, imagen, 2
  descripciones)

Estandar UI o custom

Que podemos hacer?

  Listar todos los achievements, Consultar
  los ganados, reportar progreso, resetar
Achievements - Traer
                    todos
[GKAchievementDescription loadAchievementDescriptionsWithCompletionHandler:
^(NSArray *descriptions, NSError *error) {

      if (descriptions) {
              // Array de GKAchievementDescriptions, info cacheada , trae
              // ocultos!!
      }
      if (error) {

      }

}];
Achievements - Reportar
                 progreso
GKAchievement *achievement = [[[GKAchievement alloc]
initWithIdentifier:@"identifier"] autorelease];

achievement.percentComplete = 100.0f;

[achievement reportAchievementWithCompletionHandler:^(NSError *error) {

      if (error) {
           // que hacemos? GKAchievement tambien soporta NSCoding
      } else {

      }

}];
Achievements -
      Consultar los ganados
[GKAchievement loadAchievementsWithCompletionHandler:
^(NSArray *achievements, NSError *error) {

      if (achievements) {
           // Array de GKAchievements, puede ser info cacheada
      }
      if (error) {

      }

}];
Matchmaking
Quiero arrancar una partida multiplayer!

Cantidad de jugadores (min/max)

Auto-match: Sobre jugadores que estan
esperando comenzar a jugar

Invitación:

  Sobre jugadores epecificos, amigos
  generalmente. Los cuales:

     Pueden estar jungado la app

     Pueden no estar jugando la app

     No esta jungado ni tiene la app instalada
Matchmaking

Opciones para implementar matchmaking:

  Estandar UI

  Custom: custom UI o simplemente un boton
  (solo para Auto-match)

Estan todos los jugadores, y ahora?:

  Peer-to-peer (GKMatch)

  Juego hosteado por nosotros (PlayerIDs)
Matchmaking - Crear un
        match (Estandar UI)
GKMatchRequest *matchRequest = [[[GKMatchRequest
alloc] init] autorelease];
matchRequest.minPlayers = 2;
matchRequest.maxPlayers = 2;

GKMatchmakerViewController *viewController =
[[GKMatchmakerViewController alloc]
initWithMatchRequest:matchRequest];

viewController.hosted = NO;

viewController.matchmakerDelegate = self;

[self presentModalViewController:viewController
animated:YES];

[viewController release];
Matchmaking - Crear un
         match (Estandar UI)
- (void)matchmakerViewControllerWasCancelled:(GKMatchmakerViewController
*)viewController {
    // Dismiss view controller
}

- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController
didFailWithError:(NSError *)error {
    // Dismiss view controller y mostrar error
}

- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController
didFindMatch:(GKMatch *)match {
    // Comenzar el juego usando GKMatch
}

- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController
didFindPlayers:(NSArray *)playerIDs {
    // Comenzar el juego usando el array de playerIDs
}
Matchmaking - Crear un
             match (custom)
GKMatchRequest *matchRequest = [[[GKMatchRequest alloc] init] autorelease];
matchRequest.minPlayers = 2;
matchRequest.maxPlayers = 4;

[[GKMatchmaker sharedMatchmaker] findMatchForRequest:matchRequest
withCompletionHandler:^(GKMatch *match, NSError *error) {

      if (!error) {

          // Hacer algo con GKMatch

      }

}];
GKMatch

Maneja la comunicación durante una partida

Recibe datos de otros jugadores (NSData)

Envía datos a otros jugadores (NSData)

Inicia el chat de voz
GKMatch
  Enviar datos a los otros jugadores
NSData *data = ...;
NSError *error = nil
[match sendDataToAllPlayers:data withDataMode:GKMatchSendDataReliable
error:&error];


  Desconectarme de un partido
[match disconnect];
GKMatch
  GKMatchDelegate
- (void)match:(GKMatch *)match didReceiveData:(NSData *)data fromPlayer:(NSString
*)playerID {
      // Procesar informacion recibida
}

- (void)match:(GKMatch *)match player:(NSString *)playerID didChangeState:
(GKPlayerConnectionState)state {
      // Procesar desconexión de un jugador
}


- (void)match:(GKMatch *)match connectionWithPlayerFailed:(NSString *)playerID
withError:(NSError *)error {
      // Procesar error de conexión
}

- (void)match:(GKMatch *)match didFailWithError:(NSError *)error {
      // Procesar error de conexión con todos los jugadores
}
GKInvite
[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite,
NSArray *playersToInvite) {

    if (acceptedInvite) {

          GKMatchmakerViewController *vc = [[[GKMatchmakerViewController alloc]
          initWithInvite:acceptedInvite] autorelease];
          vc.matchmakerDelegate = self;
          [self presentModalViewController:mmvc animated:YES];

    } else if (playersToInvite) {

          GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
          request.minPlayers = 2;
          request.maxPlayers = 4;
          request.playersToInvite = playersToInvite;
          GKMatchmakerViewController *vc = [[[GKMatchmakerViewController alloc]
          initWithMatchRequest:request] autorelease];
          vc.matchmakerDelegate = self;
          [self presentModalViewController:mmvc animated:YES];
    }];
}
Chequear si Game
Center esta presente
Puede no estar si:

  < iOS 4.1

  iPhone 3g, iPod 1ra generación

Para esos casos:

  Weak reference al framework

  Y el siguiente código:
Chequear si Game
    Center esta presente
Class gameCenterPlayerClass = NSClassFromString(@"GKLocalPlayer");

if (gameCenterPlayerClass != nil) {
     NSString *reqSysVer = @"4.1";
     NSString *currSysVer = [[UIDevice currentDevice] systemVersion];

    if ([currSysVer compare:reqSysVer
                  options:NSNumericSearch] != NSOrderedAscending) {

        return YES;

    }
}

return NO;
Entornos

Simulador: Sandbox

Developer build (device): Sandbox

Ad-Hoc distribution build: Sandbox

App Store build: Producción
iOS 5: Que hay de
     nuevo?
GKTurnBasedMatch

GKNotificationBanner

GKAchievement (show banner)

GKPlayer (Profile picture)

Mejoras en la app Game Center
Ventajas / Limitaciones
Ventajas

  Mucha funcionalidad gratis

  Facil de usar

  Visibilidad

Limitaciones

  Version iOS y dispositivos

  Matchmaking y peer-to-peer solo usuarios GC

  UI no es 100% customizable
Que no vimos
Manejar GKInvite

Multitasking: Algunos issues en iOS 4.1, resueltos
en iOS 4.2

Aggregate Leaderboards

Matchmaking avanzado: groups (level), attributes
(rol)

Hostear un juego

Voice chat con GKMatch

Otras funciones de GameKit: Peer-to-peer, In-Game
voice
Para seguir leyendo
Beginning iOS Game Center and Game Kit (Apress)

WWDC 2010 y 2011 videos: http://developer.apple.com/videos/wwdc/2010/

Game Kit Programming Guide: http://developer.apple.com/library/ios/
#documentation/NetworkingInternet/Conceptual/GameKit_Guide/
Introduction/Introduction.html

http://www.raywenderlich.com/tutorials

Proyectos GKTapper y GKTank
Gracias!

Más contenido relacionado

Destacado

iOS dev group - Introduccion core data
iOS dev group - Introduccion core dataiOS dev group - Introduccion core data
iOS dev group - Introduccion core datamicroeditionbiz
 
EVA 2010 Introduccion a Core Data en iPhone
EVA 2010 Introduccion a Core Data en iPhoneEVA 2010 Introduccion a Core Data en iPhone
EVA 2010 Introduccion a Core Data en iPhonemicroeditionbiz
 
5 Steps To A Smart Compensation Plan
5 Steps To A Smart Compensation Plan5 Steps To A Smart Compensation Plan
5 Steps To A Smart Compensation PlanBambooHR
 
10 Tips for WeChat
10 Tips for WeChat10 Tips for WeChat
10 Tips for WeChatChris Baker
 
Benefits of drinking water
Benefits of drinking waterBenefits of drinking water
Benefits of drinking waterEason Chan
 

Destacado (6)

iOS dev group - Introduccion core data
iOS dev group - Introduccion core dataiOS dev group - Introduccion core data
iOS dev group - Introduccion core data
 
EVA 2010 Introduccion a Core Data en iPhone
EVA 2010 Introduccion a Core Data en iPhoneEVA 2010 Introduccion a Core Data en iPhone
EVA 2010 Introduccion a Core Data en iPhone
 
5 Steps To A Smart Compensation Plan
5 Steps To A Smart Compensation Plan5 Steps To A Smart Compensation Plan
5 Steps To A Smart Compensation Plan
 
Stay Up To Date on the Latest Happenings in the Boardroom: Recommended Summer...
Stay Up To Date on the Latest Happenings in the Boardroom: Recommended Summer...Stay Up To Date on the Latest Happenings in the Boardroom: Recommended Summer...
Stay Up To Date on the Latest Happenings in the Boardroom: Recommended Summer...
 
10 Tips for WeChat
10 Tips for WeChat10 Tips for WeChat
10 Tips for WeChat
 
Benefits of drinking water
Benefits of drinking waterBenefits of drinking water
Benefits of drinking water
 

Similar a Integrando Game Center en iOS

Desarrollando aplicaciones web usando Catalyst y jQuery
Desarrollando aplicaciones web usando Catalyst y jQueryDesarrollando aplicaciones web usando Catalyst y jQuery
Desarrollando aplicaciones web usando Catalyst y jQueryJavier P.
 
Desarrollo de aplicaciones web usando Catalyst y jQuery
Desarrollo de aplicaciones web usando Catalyst y jQueryDesarrollo de aplicaciones web usando Catalyst y jQuery
Desarrollo de aplicaciones web usando Catalyst y jQueryJavier P.
 
Reactividad en Angular, React y VueJS
Reactividad en Angular, React y VueJSReactividad en Angular, React y VueJS
Reactividad en Angular, React y VueJSJavier Abadía
 
Android Bootcamp - GTUG Uruguay
Android Bootcamp - GTUG UruguayAndroid Bootcamp - GTUG Uruguay
Android Bootcamp - GTUG Uruguaygtuguruguay
 
eyeOS: Arquitectura y desarrollo de una aplicación
eyeOS: Arquitectura y desarrollo de una aplicacióneyeOS: Arquitectura y desarrollo de una aplicación
eyeOS: Arquitectura y desarrollo de una aplicaciónJose Luis Lopez Pino
 
Introducción a AngularJS
Introducción a AngularJS Introducción a AngularJS
Introducción a AngularJS Marcos Reynoso
 
Desarrollo de aplicaciones web usando Catalyst y jQuery
Desarrollo de aplicaciones web usando Catalyst y jQueryDesarrollo de aplicaciones web usando Catalyst y jQuery
Desarrollo de aplicaciones web usando Catalyst y jQueryJavier P.
 
.NET UY Meetup 5 - MVC For Human Beings by Leonardo Botta
.NET UY Meetup 5 - MVC For Human Beings by Leonardo Botta.NET UY Meetup 5 - MVC For Human Beings by Leonardo Botta
.NET UY Meetup 5 - MVC For Human Beings by Leonardo Botta.NET UY Meetup
 
HTML 5 & WebGL (Spanish Version)
HTML 5 & WebGL (Spanish Version)HTML 5 & WebGL (Spanish Version)
HTML 5 & WebGL (Spanish Version)Iran Reyes Fleitas
 
Google maps by Jordan Diaz
Google maps by Jordan DiazGoogle maps by Jordan Diaz
Google maps by Jordan DiazJordan Diaz
 

Similar a Integrando Game Center en iOS (20)

Google Play Games Services
Google Play Games ServicesGoogle Play Games Services
Google Play Games Services
 
Curso AngularJS - 7. temas avanzados
Curso AngularJS - 7. temas avanzadosCurso AngularJS - 7. temas avanzados
Curso AngularJS - 7. temas avanzados
 
Desarrollando aplicaciones web usando Catalyst y jQuery
Desarrollando aplicaciones web usando Catalyst y jQueryDesarrollando aplicaciones web usando Catalyst y jQuery
Desarrollando aplicaciones web usando Catalyst y jQuery
 
Gwt III - Avanzado
Gwt III - AvanzadoGwt III - Avanzado
Gwt III - Avanzado
 
Desarrollo de aplicaciones web usando Catalyst y jQuery
Desarrollo de aplicaciones web usando Catalyst y jQueryDesarrollo de aplicaciones web usando Catalyst y jQuery
Desarrollo de aplicaciones web usando Catalyst y jQuery
 
Reactividad en Angular, React y VueJS
Reactividad en Angular, React y VueJSReactividad en Angular, React y VueJS
Reactividad en Angular, React y VueJS
 
Presentacion03
Presentacion03Presentacion03
Presentacion03
 
Clase03
Clase03Clase03
Clase03
 
Presentacion03
Presentacion03Presentacion03
Presentacion03
 
Clase03
Clase03Clase03
Clase03
 
Android Bootcamp - GTUG Uruguay
Android Bootcamp - GTUG UruguayAndroid Bootcamp - GTUG Uruguay
Android Bootcamp - GTUG Uruguay
 
Web Mapping con Django
Web Mapping con DjangoWeb Mapping con Django
Web Mapping con Django
 
Segunda sesion
Segunda sesionSegunda sesion
Segunda sesion
 
eyeOS: Arquitectura y desarrollo de una aplicación
eyeOS: Arquitectura y desarrollo de una aplicacióneyeOS: Arquitectura y desarrollo de una aplicación
eyeOS: Arquitectura y desarrollo de una aplicación
 
APIREST LARAVEL Y PHP.pptx
APIREST LARAVEL Y PHP.pptxAPIREST LARAVEL Y PHP.pptx
APIREST LARAVEL Y PHP.pptx
 
Introducción a AngularJS
Introducción a AngularJS Introducción a AngularJS
Introducción a AngularJS
 
Desarrollo de aplicaciones web usando Catalyst y jQuery
Desarrollo de aplicaciones web usando Catalyst y jQueryDesarrollo de aplicaciones web usando Catalyst y jQuery
Desarrollo de aplicaciones web usando Catalyst y jQuery
 
.NET UY Meetup 5 - MVC For Human Beings by Leonardo Botta
.NET UY Meetup 5 - MVC For Human Beings by Leonardo Botta.NET UY Meetup 5 - MVC For Human Beings by Leonardo Botta
.NET UY Meetup 5 - MVC For Human Beings by Leonardo Botta
 
HTML 5 & WebGL (Spanish Version)
HTML 5 & WebGL (Spanish Version)HTML 5 & WebGL (Spanish Version)
HTML 5 & WebGL (Spanish Version)
 
Google maps by Jordan Diaz
Google maps by Jordan DiazGoogle maps by Jordan Diaz
Google maps by Jordan Diaz
 

Último

Trabajo Mas Completo De Excel en clase tecnología
Trabajo Mas Completo De Excel en clase tecnologíaTrabajo Mas Completo De Excel en clase tecnología
Trabajo Mas Completo De Excel en clase tecnologíassuserf18419
 
International Women's Day Sucre 2024 (IWD)
International Women's Day Sucre 2024 (IWD)International Women's Day Sucre 2024 (IWD)
International Women's Day Sucre 2024 (IWD)GDGSucre
 
Global Azure Lima 2024 - Integración de Datos con Microsoft Fabric
Global Azure Lima 2024 - Integración de Datos con Microsoft FabricGlobal Azure Lima 2024 - Integración de Datos con Microsoft Fabric
Global Azure Lima 2024 - Integración de Datos con Microsoft FabricKeyla Dolores Méndez
 
guía de registro de slideshare por Brayan Joseph
guía de registro de slideshare por Brayan Josephguía de registro de slideshare por Brayan Joseph
guía de registro de slideshare por Brayan JosephBRAYANJOSEPHPEREZGOM
 
Presentación guía sencilla en Microsoft Excel.pptx
Presentación guía sencilla en Microsoft Excel.pptxPresentación guía sencilla en Microsoft Excel.pptx
Presentación guía sencilla en Microsoft Excel.pptxLolaBunny11
 
trabajotecologiaisabella-240424003133-8f126965.pdf
trabajotecologiaisabella-240424003133-8f126965.pdftrabajotecologiaisabella-240424003133-8f126965.pdf
trabajotecologiaisabella-240424003133-8f126965.pdfIsabellaMontaomurill
 
CLASE DE TECNOLOGIA E INFORMATICA PRIMARIA
CLASE  DE TECNOLOGIA E INFORMATICA PRIMARIACLASE  DE TECNOLOGIA E INFORMATICA PRIMARIA
CLASE DE TECNOLOGIA E INFORMATICA PRIMARIAWilbisVega
 
KELA Presentacion Costa Rica 2024 - evento Protégeles
KELA Presentacion Costa Rica 2024 - evento ProtégelesKELA Presentacion Costa Rica 2024 - evento Protégeles
KELA Presentacion Costa Rica 2024 - evento ProtégelesFundación YOD YOD
 
Redes direccionamiento y subredes ipv4 2024 .pdf
Redes direccionamiento y subredes ipv4 2024 .pdfRedes direccionamiento y subredes ipv4 2024 .pdf
Redes direccionamiento y subredes ipv4 2024 .pdfsoporteupcology
 
9egb-lengua y Literatura.pdf_texto del estudiante
9egb-lengua y Literatura.pdf_texto del estudiante9egb-lengua y Literatura.pdf_texto del estudiante
9egb-lengua y Literatura.pdf_texto del estudianteAndreaHuertas24
 
pruebas unitarias unitarias en java con JUNIT
pruebas unitarias unitarias en java con JUNITpruebas unitarias unitarias en java con JUNIT
pruebas unitarias unitarias en java con JUNITMaricarmen Sánchez Ruiz
 
Herramientas de corte de alta velocidad.pptx
Herramientas de corte de alta velocidad.pptxHerramientas de corte de alta velocidad.pptx
Herramientas de corte de alta velocidad.pptxRogerPrieto3
 
Proyecto integrador. Las TIC en la sociedad S4.pptx
Proyecto integrador. Las TIC en la sociedad S4.pptxProyecto integrador. Las TIC en la sociedad S4.pptx
Proyecto integrador. Las TIC en la sociedad S4.pptx241521559
 
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...silviayucra2
 
EPA-pdf resultado da prova presencial Uninove
EPA-pdf resultado da prova presencial UninoveEPA-pdf resultado da prova presencial Uninove
EPA-pdf resultado da prova presencial UninoveFagnerLisboa3
 

Último (15)

Trabajo Mas Completo De Excel en clase tecnología
Trabajo Mas Completo De Excel en clase tecnologíaTrabajo Mas Completo De Excel en clase tecnología
Trabajo Mas Completo De Excel en clase tecnología
 
International Women's Day Sucre 2024 (IWD)
International Women's Day Sucre 2024 (IWD)International Women's Day Sucre 2024 (IWD)
International Women's Day Sucre 2024 (IWD)
 
Global Azure Lima 2024 - Integración de Datos con Microsoft Fabric
Global Azure Lima 2024 - Integración de Datos con Microsoft FabricGlobal Azure Lima 2024 - Integración de Datos con Microsoft Fabric
Global Azure Lima 2024 - Integración de Datos con Microsoft Fabric
 
guía de registro de slideshare por Brayan Joseph
guía de registro de slideshare por Brayan Josephguía de registro de slideshare por Brayan Joseph
guía de registro de slideshare por Brayan Joseph
 
Presentación guía sencilla en Microsoft Excel.pptx
Presentación guía sencilla en Microsoft Excel.pptxPresentación guía sencilla en Microsoft Excel.pptx
Presentación guía sencilla en Microsoft Excel.pptx
 
trabajotecologiaisabella-240424003133-8f126965.pdf
trabajotecologiaisabella-240424003133-8f126965.pdftrabajotecologiaisabella-240424003133-8f126965.pdf
trabajotecologiaisabella-240424003133-8f126965.pdf
 
CLASE DE TECNOLOGIA E INFORMATICA PRIMARIA
CLASE  DE TECNOLOGIA E INFORMATICA PRIMARIACLASE  DE TECNOLOGIA E INFORMATICA PRIMARIA
CLASE DE TECNOLOGIA E INFORMATICA PRIMARIA
 
KELA Presentacion Costa Rica 2024 - evento Protégeles
KELA Presentacion Costa Rica 2024 - evento ProtégelesKELA Presentacion Costa Rica 2024 - evento Protégeles
KELA Presentacion Costa Rica 2024 - evento Protégeles
 
Redes direccionamiento y subredes ipv4 2024 .pdf
Redes direccionamiento y subredes ipv4 2024 .pdfRedes direccionamiento y subredes ipv4 2024 .pdf
Redes direccionamiento y subredes ipv4 2024 .pdf
 
9egb-lengua y Literatura.pdf_texto del estudiante
9egb-lengua y Literatura.pdf_texto del estudiante9egb-lengua y Literatura.pdf_texto del estudiante
9egb-lengua y Literatura.pdf_texto del estudiante
 
pruebas unitarias unitarias en java con JUNIT
pruebas unitarias unitarias en java con JUNITpruebas unitarias unitarias en java con JUNIT
pruebas unitarias unitarias en java con JUNIT
 
Herramientas de corte de alta velocidad.pptx
Herramientas de corte de alta velocidad.pptxHerramientas de corte de alta velocidad.pptx
Herramientas de corte de alta velocidad.pptx
 
Proyecto integrador. Las TIC en la sociedad S4.pptx
Proyecto integrador. Las TIC en la sociedad S4.pptxProyecto integrador. Las TIC en la sociedad S4.pptx
Proyecto integrador. Las TIC en la sociedad S4.pptx
 
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
 
EPA-pdf resultado da prova presencial Uninove
EPA-pdf resultado da prova presencial UninoveEPA-pdf resultado da prova presencial Uninove
EPA-pdf resultado da prova presencial Uninove
 

Integrando Game Center en iOS

  • 1. Integrando Game Center en iOS Pablo Ezequiel Romero http://about.me/pabloromero
  • 2. Agenda Que es Game Center? Características Configuración / integración Repaso features mas importantes iOS 5 Ventajas / limitaciones Temas mas avanzados Para seguir leyendo
  • 3. Que es Game Center? Una iOS app Un conjunto de servicios Un API
  • 4. Que funcionalidad provee? Autenticación Matchmaking Lista de Amigos Peer-to-peer Leaderboards Voice chat Achievements
  • 5. Características de Game Center Es parte de GameKit (disponible desde iOS 3.0) >= iOS 4.1, no compatible con iPhone 3g ni iPod 1ra generación Algunas cosas no se puede probar en el simulador Entornos: sandbox / producción
  • 6. Características del API Posts y requests Estandar UI vs custom Funciones asicrónicas Blocks Si un post falla es tu responsabilidad Infomación cacheada
  • 7. Manos a la obra! 1. Crear la app en iTunes Connect 2. Habilitar Game Center 3. Setear el Bundle ID en nuestra app 4. Agregar GameKit.framework 5. Import <GameKit/GameKit.h> 6. Opcional o no
  • 8. Autenticación Lo antes posible playerID: único, el mismo en distintos dispositivos Atributos propios Tres escenarios: Usuario ya logueado Usuario no logueado, pero ya registrado Usuario no logueado, sin registrar
  • 9. Autenticación GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; [localPlayer authenticateWithCompletionHandler:^(NSError *error) { if (error) { // Error } }];
  • 10. Lista de amigos Obtener una lista de playerIDs Obtener una lista de GKPlayers Incorporar servicios no soportados por GC: Atributos propios Enviar gifts Enviar mensajes Las amistades se crean desde Game Center app. GKFriendRequestComposeViewController (iOS 4.2 )
  • 11. Lista de amigos Lista playerIDs GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; [localPlayer loadFriendsWithCompletionHandler:^(NSArray *identifiers, NSError *error) { if (identifiers) { // Array de player identifiers, puede ser info cacheada } if (error) { } }]; Lista GKPlayers [GKPlayer loadPlayersForIdentifiers:identifiers WithCompletionHandler:^(NSArray *friends, NSError *error) { if (friends) { // Array de GKPlayer } if (error) { } }];
  • 12. Leaderboards De todos los gustos y colores Se configura desde iTunes connect, muy simple (es un ABM) Id, orden, tipo (entero, dinero, decimal, tiempo) Localizable (nombre, imagen, sufijo, formato) Máximo de 25 Default Estandar UI o custom
  • 13. Leaderboards - Reportando un score GKScore *score = [[[GKScore alloc] initWithCategory:@"identifier"] autorelease]; score.value = 100; [score reportScoreWithCompletionHandler:^(NSError *error){ if (error) { // Salvar o no? GKScore soporta NSCoding } else { } }];
  • 14. Leaderboards - Listando scores GKLeaderboard *leaderboard = [[[GKLeaderboard alloc] initWithCategory:@”identifier”] autorelease]; leaderboard.timeScope = GKLeaderboardTimeScopeWeek; leaderboard.friendScope = GKLeaderboardPlayerScopeFriendsOnly; leaderboard.range = NSMakeRange(1,25); [leaderboard loadScoresWithCompletionHandler:^(NSArray *scores, NSError *error) { if (scores) { // Array de GKScore, puede ser info cacheada } if (error) { } }];
  • 15. Achievements Se configura desde iTunes connect, tambien muy simple Id, oculto Localizable (nombre, imagen, 2 descripciones) Estandar UI o custom Que podemos hacer? Listar todos los achievements, Consultar los ganados, reportar progreso, resetar
  • 16. Achievements - Traer todos [GKAchievementDescription loadAchievementDescriptionsWithCompletionHandler: ^(NSArray *descriptions, NSError *error) { if (descriptions) { // Array de GKAchievementDescriptions, info cacheada , trae // ocultos!! } if (error) { } }];
  • 17. Achievements - Reportar progreso GKAchievement *achievement = [[[GKAchievement alloc] initWithIdentifier:@"identifier"] autorelease]; achievement.percentComplete = 100.0f; [achievement reportAchievementWithCompletionHandler:^(NSError *error) { if (error) { // que hacemos? GKAchievement tambien soporta NSCoding } else { } }];
  • 18. Achievements - Consultar los ganados [GKAchievement loadAchievementsWithCompletionHandler: ^(NSArray *achievements, NSError *error) { if (achievements) { // Array de GKAchievements, puede ser info cacheada } if (error) { } }];
  • 19. Matchmaking Quiero arrancar una partida multiplayer! Cantidad de jugadores (min/max) Auto-match: Sobre jugadores que estan esperando comenzar a jugar Invitación: Sobre jugadores epecificos, amigos generalmente. Los cuales: Pueden estar jungado la app Pueden no estar jugando la app No esta jungado ni tiene la app instalada
  • 20. Matchmaking Opciones para implementar matchmaking: Estandar UI Custom: custom UI o simplemente un boton (solo para Auto-match) Estan todos los jugadores, y ahora?: Peer-to-peer (GKMatch) Juego hosteado por nosotros (PlayerIDs)
  • 21. Matchmaking - Crear un match (Estandar UI) GKMatchRequest *matchRequest = [[[GKMatchRequest alloc] init] autorelease]; matchRequest.minPlayers = 2; matchRequest.maxPlayers = 2; GKMatchmakerViewController *viewController = [[GKMatchmakerViewController alloc] initWithMatchRequest:matchRequest]; viewController.hosted = NO; viewController.matchmakerDelegate = self; [self presentModalViewController:viewController animated:YES]; [viewController release];
  • 22. Matchmaking - Crear un match (Estandar UI) - (void)matchmakerViewControllerWasCancelled:(GKMatchmakerViewController *)viewController { // Dismiss view controller } - (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFailWithError:(NSError *)error { // Dismiss view controller y mostrar error } - (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match { // Comenzar el juego usando GKMatch } - (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindPlayers:(NSArray *)playerIDs { // Comenzar el juego usando el array de playerIDs }
  • 23. Matchmaking - Crear un match (custom) GKMatchRequest *matchRequest = [[[GKMatchRequest alloc] init] autorelease]; matchRequest.minPlayers = 2; matchRequest.maxPlayers = 4; [[GKMatchmaker sharedMatchmaker] findMatchForRequest:matchRequest withCompletionHandler:^(GKMatch *match, NSError *error) { if (!error) { // Hacer algo con GKMatch } }];
  • 24. GKMatch Maneja la comunicación durante una partida Recibe datos de otros jugadores (NSData) Envía datos a otros jugadores (NSData) Inicia el chat de voz
  • 25. GKMatch Enviar datos a los otros jugadores NSData *data = ...; NSError *error = nil [match sendDataToAllPlayers:data withDataMode:GKMatchSendDataReliable error:&error]; Desconectarme de un partido [match disconnect];
  • 26. GKMatch GKMatchDelegate - (void)match:(GKMatch *)match didReceiveData:(NSData *)data fromPlayer:(NSString *)playerID { // Procesar informacion recibida } - (void)match:(GKMatch *)match player:(NSString *)playerID didChangeState: (GKPlayerConnectionState)state { // Procesar desconexión de un jugador } - (void)match:(GKMatch *)match connectionWithPlayerFailed:(NSString *)playerID withError:(NSError *)error { // Procesar error de conexión } - (void)match:(GKMatch *)match didFailWithError:(NSError *)error { // Procesar error de conexión con todos los jugadores }
  • 27. GKInvite [GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite) { if (acceptedInvite) { GKMatchmakerViewController *vc = [[[GKMatchmakerViewController alloc] initWithInvite:acceptedInvite] autorelease]; vc.matchmakerDelegate = self; [self presentModalViewController:mmvc animated:YES]; } else if (playersToInvite) { GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease]; request.minPlayers = 2; request.maxPlayers = 4; request.playersToInvite = playersToInvite; GKMatchmakerViewController *vc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease]; vc.matchmakerDelegate = self; [self presentModalViewController:mmvc animated:YES]; }]; }
  • 28. Chequear si Game Center esta presente Puede no estar si: < iOS 4.1 iPhone 3g, iPod 1ra generación Para esos casos: Weak reference al framework Y el siguiente código:
  • 29. Chequear si Game Center esta presente Class gameCenterPlayerClass = NSClassFromString(@"GKLocalPlayer"); if (gameCenterPlayerClass != nil) { NSString *reqSysVer = @"4.1"; NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) { return YES; } } return NO;
  • 30. Entornos Simulador: Sandbox Developer build (device): Sandbox Ad-Hoc distribution build: Sandbox App Store build: Producción
  • 31. iOS 5: Que hay de nuevo? GKTurnBasedMatch GKNotificationBanner GKAchievement (show banner) GKPlayer (Profile picture) Mejoras en la app Game Center
  • 32. Ventajas / Limitaciones Ventajas Mucha funcionalidad gratis Facil de usar Visibilidad Limitaciones Version iOS y dispositivos Matchmaking y peer-to-peer solo usuarios GC UI no es 100% customizable
  • 33. Que no vimos Manejar GKInvite Multitasking: Algunos issues en iOS 4.1, resueltos en iOS 4.2 Aggregate Leaderboards Matchmaking avanzado: groups (level), attributes (rol) Hostear un juego Voice chat con GKMatch Otras funciones de GameKit: Peer-to-peer, In-Game voice
  • 34. Para seguir leyendo Beginning iOS Game Center and Game Kit (Apress) WWDC 2010 y 2011 videos: http://developer.apple.com/videos/wwdc/2010/ Game Kit Programming Guide: http://developer.apple.com/library/ios/ #documentation/NetworkingInternet/Conceptual/GameKit_Guide/ Introduction/Introduction.html http://www.raywenderlich.com/tutorials Proyectos GKTapper y GKTank

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n