From b9e5e9896bc686d47f2a98c28a00972f901614f9 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Tue, 2 Oct 2012 13:29:59 -0300 Subject: [PATCH] Updated iOS Readme to reflect Game Center integration changes. --- README.iOS | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/README.iOS b/README.iOS index 3ec1e0f86..694b86076 100644 --- a/README.iOS +++ b/README.iOS @@ -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; +} \ No newline at end of file