Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Updated iOS Readme to reflect Game Center integration changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabomdq committed Oct 2, 2012
1 parent 8be1341 commit b9e5e98
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions README.iOS
Expand Up @@ -128,3 +128,41 @@ Audio:
Loading Shared Objects:
This is disabled by default since it seems to break the terms of the iPhone SDK agreement. It can be re-enabled in SDL_config_iphoneos.h.

==============================================================================
Game Center
==============================================================================

Game Center integration requires that you break up your main loop in order to yield control back to the system. In other words, instead of running an endless main loop, you run each frame in a callback function, using:

int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);

This will set up the given function to be called back on the animation callback, and then you have to return from main() to let the Cocoa event loop run.

e.g.

extern "C"
void ShowFrame(void*)
{
... do frame logic and rendering
}

int main(int argc, char *argv[])
{
... initialize game ...

#if __IPHONEOS__
// Initialize the Game Center for scoring and matchmaking
InitGameCenter();

// Set up the game to run in the window animation callback on iOS
// so that Game Center and so forth works correctly.
SDL_iPhoneSetAnimationCallback(screen->GetWindow(), 1, ShowFrame, 0);
#else
while ( gRunning ) {
ShowFrame(0);
DelayFrame();
}
CleanUp();
#endif
return 0;
}

0 comments on commit b9e5e98

Please sign in to comment.