How to make SDL 2.0, iOS work together. (Game Center too) |
Sam Lantinga
|
Thanks BJ, this was incredibly helpful adding Game Center support to Maelstrom. :)
I added a function to SDL to make this easier to hook up: 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; } On Thu, May 3, 2012 at 12:27 AM, BJ wrote:
|
|||||||||||||
|
How to make SDL 2.0, iOS work together. (Game Center too) |
gabomdq
|
That is awesome, I think that pseudo code you posted should go in the iOS readme.
El 22/06/2012 20:23, "Sam Lantinga" escribió:
|
|||||||||||||||
|
Re: How to make SDL 2.0, iOS work together. (Game Center too |
stevo5800
|
Sam that function works like a charm, I was able to use that function to run my main loop then use the initialize stuff from BJ. I successfully launched game centre in my app but now the issue is how to get the welcome back message to pop up, or even any notification banner from game kit. If I don't render then I see the banner if not it draws over it. I got the idea of checking for views but it seems to only show the SDL view. I base my self of the SDL template included in the SDK. So I was wondering if there was a way to to display this banner?
Thanks
|
|||||||||||||||
|
How to make SDL 2.0, iOS work together. (Game Center too) |
Sam Lantinga
|
No idea... anyone?
On Wed, Jul 4, 2012 at 5:09 AM, stevo5800 wrote:
|
|||||||||||||
|
How to make SDL 2.0, iOS work together. (Game Center too) |
Ye Xing
Guest
|
- (void) authenticateLocalUser
{ Â Â [self becomeFirstResponder]; Â Â Â Â Â if([GKLocalPlayer localPlayer].authenticated == NO) Â Â { Â Â Â Â [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) Â Â Â Â { Â Â Â Â Â Â if(error == nil) Â Â Â Â Â Â { Â Â Â Â Â Â Â Â Â SDL_Delay(1000); 2012/7/5 Sam Lantinga
-- Best Regards |
|||||||||||||||
|
Re: How to make SDL 2.0, iOS work together. (Game Center too |
stevo5800
|
So I tried the above and had no success. After looking at the keyboard code I realized its creating a new window. So I decide to do window count and it happens that game center is doing the same thing as soon as the banner came up it showed another window opening. So I decided to trap any window that opens up .
this code is assuming there will be no other windows popping up but you could always add a count for other windows that is open and just do the math not sure if it was the best solution but it works and now I understand how its working //check if theres more then one window if([[UIApplication sharedApplication].windows count] > 1) { if(one_time) { //getting the current window UIWindow *main_window = [[UIApplication sharedApplication] keyWindow]; //get the new window UIWindow *window = [[[UIApplication sharedApplication] windows] lastObject]; //add the second window view to the main window [main_window addSubview:window.superview]; //set window level window.windowLevel = 1; //run this once every time it opens a new window one_time = false; } } else { //reset the flag when window closes one_time = true; }
|
|||||||||||||||||
|
How to make SDL 2.0, iOS work together. (Game Center too) |
Sam Lantinga
|
David Ludwig discovered the issue with the game center being hidden, and I put in an untested fix:http://hg.libsdl.org/SDL/rev/8f224d0762ab
Can you let me know if this works? I should be able to test iOS stuff again in a week or so. On Wed, Jul 4, 2012 at 5:09 AM, stevo5800 wrote:
|
|||||||||||||
|
Re: How to make SDL 2.0, iOS work together. (Game Center too |
stevo5800
|
I got a black screen but the banner shows up
|
|||||||||||||||
|
How to make SDL 2.0, iOS work together. (Game Center too) |
Sam Lantinga
|
If you revert that patch, do you get a normal (non-black) screen and no banner?
On Sun, Jul 22, 2012 at 3:39 PM, stevo5800 wrote:
|
|||||||||||||
|
Re: How to make SDL 2.0, iOS work together. (Game Center too |
stevo5800
|
Yea I used it on an existing project switch back to my old SDL folder no black screen but banner behind
|
|||||||||||||||
|
How to make SDL 2.0, iOS work together. (Game Center too) |
DLudwig
|
Hi all,
I did a similar fix to a much older version of SDL 1.3 for iOS, had a blank screen on launch, and eventually found a fix. At the time, I was working on a port of a commercial, Windows-based app to iOS. Early in the project, the app would launch ok, but there'd be a blank screen. Once the app did its first draw cycle, it'd go away. The fix ended up being to make SDL display, on app launch, a "splash screen" view controller. SDL would use the app's launch image (Default.png) for content, along with a UIActivityIndicator-based spinning wheel to show the user that things were happening. When SDL was asked to update the screen for the first time, the splash screen would be hidden. I hope this helps, -- David L. On Mon, Jul 23, 2012 at 5:14 AM, stevo5800 wrote:
|
|||||||||||||
|