docs/README-ios.md
changeset 9050 bc9616da37cd
parent 9025 d09d4b578e77
child 9064 428bff5bf38a
     1.1 --- a/docs/README-ios.md	Mon Aug 11 22:53:03 2014 +0200
     1.2 +++ b/docs/README-ios.md	Mon Aug 11 23:13:20 2014 +0200
     1.3 @@ -68,56 +68,56 @@
     1.4  
     1.5  e.g.
     1.6  
     1.7 -int HandleAppEvents(void *userdata, SDL_Event *event)
     1.8 -{
     1.9 -    switch (event->type)
    1.10 +    int HandleAppEvents(void *userdata, SDL_Event *event)
    1.11      {
    1.12 -    case SDL_APP_TERMINATING:
    1.13 -        /* Terminate the app.
    1.14 -           Shut everything down before returning from this function.
    1.15 -        */
    1.16 +        switch (event->type)
    1.17 +        {
    1.18 +        case SDL_APP_TERMINATING:
    1.19 +            /* Terminate the app.
    1.20 +               Shut everything down before returning from this function.
    1.21 +            */
    1.22 +            return 0;
    1.23 +        case SDL_APP_LOWMEMORY:
    1.24 +            /* You will get this when your app is paused and iOS wants more memory.
    1.25 +               Release as much memory as possible.
    1.26 +            */
    1.27 +            return 0;
    1.28 +        case SDL_APP_WILLENTERBACKGROUND:
    1.29 +            /* Prepare your app to go into the background.  Stop loops, etc.
    1.30 +               This gets called when the user hits the home button, or gets a call.
    1.31 +            */
    1.32 +            return 0;
    1.33 +        case SDL_APP_DIDENTERBACKGROUND:
    1.34 +            /* This will get called if the user accepted whatever sent your app to the background.
    1.35 +               If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops.
    1.36 +               When you get this, you have 5 seconds to save all your state or the app will be terminated.
    1.37 +               Your app is NOT active at this point.
    1.38 +            */
    1.39 +            return 0;
    1.40 +        case SDL_APP_WILLENTERFOREGROUND:
    1.41 +            /* This call happens when your app is coming back to the foreground.
    1.42 +               Restore all your state here.
    1.43 +            */
    1.44 +            return 0;
    1.45 +        case SDL_APP_DIDENTERFOREGROUND:
    1.46 +            /* Restart your loops here.
    1.47 +               Your app is interactive and getting CPU again.
    1.48 +            */
    1.49 +            return 0;
    1.50 +        default:
    1.51 +            /* No special processing, add it to the event queue */
    1.52 +            return 1;
    1.53 +        }
    1.54 +    }
    1.55 +    
    1.56 +    int main(int argc, char *argv[])
    1.57 +    {
    1.58 +        SDL_SetEventFilter(HandleAppEvents, NULL);
    1.59 +    
    1.60 +        ... run your main loop
    1.61 +    
    1.62          return 0;
    1.63 -    case SDL_APP_LOWMEMORY:
    1.64 -        /* You will get this when your app is paused and iOS wants more memory.
    1.65 -           Release as much memory as possible.
    1.66 -        */
    1.67 -        return 0;
    1.68 -    case SDL_APP_WILLENTERBACKGROUND:
    1.69 -        /* Prepare your app to go into the background.  Stop loops, etc.
    1.70 -           This gets called when the user hits the home button, or gets a call.
    1.71 -        */
    1.72 -        return 0;
    1.73 -    case SDL_APP_DIDENTERBACKGROUND:
    1.74 -        /* This will get called if the user accepted whatever sent your app to the background.
    1.75 -           If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops.
    1.76 -           When you get this, you have 5 seconds to save all your state or the app will be terminated.
    1.77 -           Your app is NOT active at this point.
    1.78 -        */
    1.79 -        return 0;
    1.80 -    case SDL_APP_WILLENTERFOREGROUND:
    1.81 -        /* This call happens when your app is coming back to the foreground.
    1.82 -           Restore all your state here.
    1.83 -        */
    1.84 -        return 0;
    1.85 -    case SDL_APP_DIDENTERFOREGROUND:
    1.86 -        /* Restart your loops here.
    1.87 -           Your app is interactive and getting CPU again.
    1.88 -        */
    1.89 -        return 0;
    1.90 -    default:
    1.91 -        /* No special processing, add it to the event queue */
    1.92 -        return 1;
    1.93      }
    1.94 -}
    1.95 -
    1.96 -int main(int argc, char *argv[])
    1.97 -{
    1.98 -    SDL_SetEventFilter(HandleAppEvents, NULL);
    1.99 -
   1.100 -    ... run your main loop
   1.101 -
   1.102 -    return 0;
   1.103 -}
   1.104  
   1.105      
   1.106  ==============================================================================
   1.107 @@ -198,28 +198,28 @@
   1.108  
   1.109  e.g.
   1.110  
   1.111 -extern "C"
   1.112 -void ShowFrame(void*)
   1.113 -{
   1.114 -    ... do event handling, frame logic and rendering
   1.115 -}
   1.116 -
   1.117 -int main(int argc, char *argv[])
   1.118 -{
   1.119 -   ... initialize game ...
   1.120 -
   1.121 -#if __IPHONEOS__
   1.122 -        // Initialize the Game Center for scoring and matchmaking
   1.123 -        InitGameCenter();
   1.124 -
   1.125 -        // Set up the game to run in the window animation callback on iOS
   1.126 -        // so that Game Center and so forth works correctly.
   1.127 -        SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL);
   1.128 -#else
   1.129 -        while ( running ) {
   1.130 -                ShowFrame(0);
   1.131 -                DelayFrame();
   1.132 -        }
   1.133 -#endif
   1.134 -        return 0;
   1.135 -}
   1.136 +    extern "C"
   1.137 +    void ShowFrame(void*)
   1.138 +    {
   1.139 +        ... do event handling, frame logic and rendering
   1.140 +    }
   1.141 +    
   1.142 +    int main(int argc, char *argv[])
   1.143 +    {
   1.144 +        ... initialize game ...
   1.145 +    
   1.146 +    #if __IPHONEOS__
   1.147 +            // Initialize the Game Center for scoring and matchmaking
   1.148 +            InitGameCenter();
   1.149 +    
   1.150 +            // Set up the game to run in the window animation callback on iOS
   1.151 +            // so that Game Center and so forth works correctly.
   1.152 +            SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL);
   1.153 +    #else
   1.154 +            while ( running ) {
   1.155 +                    ShowFrame(0);
   1.156 +                    DelayFrame();
   1.157 +            }
   1.158 +    #endif
   1.159 +            return 0;
   1.160 +    }