Game Center init freezes application momentarily

Why not just init yourself on resume?

As Game Center is still logged in all I get is this message, I don’t think I can capture specific WARNING messages…

WARNING: gameNetwork.init() was already called for gamecenter.

The work around here is to just set a timeout function after a few secs but then I might not capture the  ALL then GC auto inits which is the point of this exercise.

It’s a warning. You can ignore it.

Rob

Ok I have found some native code that would help:

Here is a way of natively checking to see if the user is logged into Game Center or not. If I could access this function I could then not bother them with the loading overlay and just let them play straight away after resume.

if([GKLocalPlayer localPlayer].isAuthenticated) { // user logged in }

Reference

http://stackoverflow.com/questions/31218209/check-if-a-game-center-account-is-logged-in

Feature request perhaps.

I’m currently writing a full featured Game Center plugin for Corona SDK that will give you more control of when the Game Center Sign In screen is shown to the player, so no need to post a feature request. I can’t say exactly when it will be ready but it’s in the final stages before I open it up for beta testing which I hope will be near the end of October.

The Corona SDK gameNetwork iOS Game Center plugin does dispatch a lua event for [GKLocalPlayer localPlayer].isAuthenticated

On lines 1017 and 1031 of the plugin: https://github.com/coronalabs/plugins-source-gamenetwork-apple/blob/master/ios/Plugin/Rtt_IPhoneGameCenter.mm

[GKLocalPlayer localPlayer].isAuthenticated YES/NO == event.data true/false

[lua]

loggedIntoGC = false – global or property on composer.loggedIntoGC

local function initCallback( event )

    if ( event.type == “showSignIn” ) then

        – This is an opportunity to pause your game or do other things you might need to do while the Game Center Sign-In screen is up.

    elseif ( event.type == “init” ) then

        if ( event.data == true ) then

            loggedIntoGC = true

        else

            loggedIntoGC = false

    end

end

[/lua]

I should add that the initCallback() gets called again after your game is resumed from being suspended so you don’t have to listen for the “applicationSuspend” and “applicationResume” “system” events and you should only have to call gameNetwork.init( “gamecenter”, initCallback ) once when your game is launched.

Thanks animonger, I will defiantly be keen on beta testing sounds like a good solution.

Cheers 

Simon

Great, I’ll post a link here when it’s ready.