Updated iOS Readme to reflect Game Center integration changes.
authorGabriel Jacobo <gabomdq@gmail.com>
Tue, 02 Oct 2012 13:29:59 -0300
changeset 65348faa51147576
parent 6533 c784245304dd
child 6535 b117349cc8aa
Updated iOS Readme to reflect Game Center integration changes.
README.iOS
     1.1 --- a/README.iOS	Tue Oct 02 00:28:23 2012 -0700
     1.2 +++ b/README.iOS	Tue Oct 02 13:29:59 2012 -0300
     1.3 @@ -128,3 +128,41 @@
     1.4  Loading Shared Objects:
     1.5  	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.
     1.6  
     1.7 +==============================================================================
     1.8 +Game Center 
     1.9 +==============================================================================
    1.10 +
    1.11 +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:
    1.12 +    
    1.13 +int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
    1.14 +
    1.15 +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.
    1.16 +
    1.17 +e.g.
    1.18 +
    1.19 +extern "C"
    1.20 +void ShowFrame(void*)
    1.21 +{
    1.22 +    ... do frame logic and rendering
    1.23 +}
    1.24 +
    1.25 +int main(int argc, char *argv[])
    1.26 +{
    1.27 +   ... initialize game ...
    1.28 +
    1.29 +#if __IPHONEOS__
    1.30 +        // Initialize the Game Center for scoring and matchmaking
    1.31 +        InitGameCenter();
    1.32 +
    1.33 +        // Set up the game to run in the window animation callback on iOS
    1.34 +        // so that Game Center and so forth works correctly.
    1.35 +        SDL_iPhoneSetAnimationCallback(screen->GetWindow(), 1, ShowFrame, 0);
    1.36 +#else
    1.37 +        while ( gRunning ) {
    1.38 +                ShowFrame(0);
    1.39 +                DelayFrame();
    1.40 +        }
    1.41 +        CleanUp();
    1.42 +#endif
    1.43 +        return 0;
    1.44 +}
    1.45 \ No newline at end of file