When to call gameNetwork.init()

Hello all,
I was implementing Openfeint when I came across this question that wasn’t answered in the Docs or API:
My app is implemented with modules using storyboard, and I previously called gameNetwork.init() at the start of every scene that used OpenFeint. However, when I do this after calling it on a different scene awhile ago, I get a warning in the terminal saying:

WARNING: gamenetwork.init() should only be called once.  

What is the proper practice for calling gameNetwork.init() with modules? Do I need to call it every module, or just in main.lua?
Thanks in advance for the help! [import]uid: 38000 topic_id: 18851 reply_id: 318851[/import]

Hey, Peter, I call gamenetwork.init() only once after my game is launched. I achieve this by using a flag/switch that I set up (like so, isGameNetworkOn = true/false). I call gamenetwork.init() if the flag = false, and I use gamenetwork.show() if the flag = true.

Naomi

Edit: by the way, your question about calling it once from main.lua, that would work fine. I use different method, but then, it’s just me. :slight_smile: [import]uid: 67217 topic_id: 18851 reply_id: 72591[/import]

Hi Naomi, is there a way to get if the player enabled openfeint or canceled it? gamenetwork.init returns nothing and sdk does not support suck function as I know, how could you handle this? [import]uid: 80068 topic_id: 18851 reply_id: 72900[/import]

Hey, @selim.anac, I don’t know the answer to your specific question, but here’s what I do. It’s my workaround:

  1. I don’t initialize OF in main.lua when user launches my game the first time.

  2. I have a button in my menu screen that accesses the OF, which initializes OF and shows the OF dashboard and asks the user if he/she wants to sign in. For this to work, all I did was to implement OF. I posted a help to the community about how to go about implementing it (and wow, I’m so thankful that we have such a helpful people on forum): https://developer.anscamobile.com/forum/2011/12/05/help-open-feint-game-center

  3. What helped me most to get the OF working was the first reply post by Burhan:

https://developer.anscamobile.com/forum/2011/12/05/help-open-feint-game-center#comment-71742

Following the instruction step-by-step described in the article, it didn’t take long to get it to work. Like the article suggests, setting up OF account takes much much longer than anything else. Coding bit is rather very simple thanks to the gameNetwork API that Corona provides.

  1. Going back to step #2 above, once a user access that screen, I save a user data (which is a simple three state flag). When the flag says that user has accessed OF button at least once and activated OF before, the next time the user launches my game, I initialize OF from the main.lua file. I figured if a user accessed the OF screen from menu screen, chances are, this user has an OF account, or at least, interested in using OF at some point. Also, initializing OF doesn’t open up the dashboard, so it won’t bother the user at all (even if he/she doesn’t want to sign in). And again, at this stage, I use the same flag for my game to know that the OF is initialized.

  2. When the user accesses OF from menu screen, it knows whether or not the OF is already initialized, and if it is already initialized, it will simply trigger the show function. (i.e., If the flag says it has not initialized OF, then it will initialize first.)

This seems to work fine for me so far. And for saving the flag/data, I use Ice Library. It does the wonders for me. You can find it here: http://developer.anscamobile.com/code/ice

I hope this helps.

Naomi

[import]uid: 67217 topic_id: 18851 reply_id: 72958[/import]

A quick update to what I noted above. I made further changes (after doing more test), and I added another screen where users can deactivate OF. Once a user choose to deactivate OF, it won’t initialize when the game launches the next time…

If only we could tell if the user has accepted the OF or not. I could really do away with the work-around, and it would make it a lot more elegant. Here’s the very same question asked by @caras:

http://developer.anscamobile.com/forum/2011/12/09/detect-if-user-accepted-openfeint [import]uid: 67217 topic_id: 18851 reply_id: 73171[/import]

Thanks a lot for your help Naomi, I will try the way you could handle it and hope I will be fine. [import]uid: 80068 topic_id: 18851 reply_id: 73514[/import]