equal
deleted
inserted
replaced
32 |
32 |
33 extern int SDL_main(int argc, char *argv[]); |
33 extern int SDL_main(int argc, char *argv[]); |
34 static int forward_argc; |
34 static int forward_argc; |
35 static char **forward_argv; |
35 static char **forward_argv; |
36 |
36 |
37 int main(int argc, char **argv) { |
37 int main (int argc, char **argv) { |
38 int i; |
38 int i; |
39 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
39 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
40 |
40 |
41 /* store arguments */ |
41 /* store arguments */ |
42 forward_argc = argc; |
42 forward_argc = argc; |
43 forward_argv = (char **)malloc(argc * sizeof(char *)); |
43 forward_argv = (char **)malloc(argc * sizeof(char *)); |
44 for (i=0; i<argc; i++) { |
44 for (i = 0; i < argc; i++) { |
45 forward_argv[i] = malloc( (strlen(argv[i])+1) * sizeof(char)); |
45 forward_argv[i] = malloc( (strlen(argv[i])+1) * sizeof(char)); |
46 strcpy(forward_argv[i], argv[i]); |
46 strcpy(forward_argv[i], argv[i]); |
47 } |
47 } |
48 |
48 |
49 /* Give over control to run loop, SDLUIKitDelegate will handle most things from here */ |
49 /* Give over control to run loop, SDLUIKitDelegate will handle most things from here */ |
76 self.window = nil; |
76 self.window = nil; |
77 |
77 |
78 /* run the user's application, passing argc and argv */ |
78 /* run the user's application, passing argc and argv */ |
79 NSLog(@"Game is launching"); |
79 NSLog(@"Game is launching"); |
80 SDL_main(forward_argc, forward_argv); |
80 SDL_main(forward_argc, forward_argv); |
|
81 // can't reach here yet |
81 NSLog(@"Game exited"); |
82 NSLog(@"Game exited"); |
82 |
83 |
83 //[self performSelector:@selector(makeNewView) withObject:nil afterDelay:0.0]; |
84 //[self performSelector:@selector(makeNewView) withObject:nil afterDelay:0.0]; |
84 /* exit, passing the return status from the user's application */ |
85 /* exit, passing the return status from the user's application */ |
85 //exit(exit_status); |
86 //exit(exit_status); |
86 } |
87 } |
87 |
88 |
97 } |
98 } |
98 |
99 |
99 -(void) applicationWillTerminate:(UIApplication *)application { |
100 -(void) applicationWillTerminate:(UIApplication *)application { |
100 /* free the memory we used to hold copies of argc and argv */ |
101 /* free the memory we used to hold copies of argc and argv */ |
101 int i; |
102 int i; |
102 for (i=0; i<forward_argc; i++) { |
103 for (i=0; i < forward_argc; i++) { |
103 free(forward_argv[i]); |
104 free(forward_argv[i]); |
104 } |
105 } |
105 free(forward_argv); |
106 free(forward_argv); |
106 SDL_SendQuit(); |
107 SDL_SendQuit(); |
107 /* hack to prevent automatic termination. See SDL_uikitevents.m for details */ |
108 /* hack to prevent automatic termination. See SDL_uikitevents.m for details */ |
108 longjmp(*(jump_env()), 1); |
109 // have to remove this otherwise game goes on when pushing the home button |
|
110 //longjmp(*(jump_env()), 1); |
|
111 |
|
112 NSLog(@"Closing App..."); |
109 } |
113 } |
110 |
114 |
111 -(void) applicationWillResignActive:(UIApplication*)application |
115 -(void) applicationWillResignActive:(UIApplication*)application |
112 { |
116 { |
113 // NSLog(@"%@", NSStringFromSelector(_cmd)); |
117 // NSLog(@"%@", NSStringFromSelector(_cmd)); |