Home Tutorials Download Beta Store Forum Documentation KnowledgeBase Wiki Blog

ShiVa3D

Return to Code Snippets

Game Center integrated!

Paste down any little snippets or request a new one.

Re: Game Center integrated!

Postby dpharaoh » 07 Mar 2011, 18:46

The only time this gets really rough is if you're doing the conversion to c++ in your scripts as well. In that case, there isn't an easy answer and you'd need to use a good merge/compare tool to carefully integrate.
dpharaoh
Platinum Boarder
Platinum Boarder
 
Posts: 1519
Location: New Bedford, MA

Re: Game Center integrated!

Postby Markuzzzz » 07 Mar 2011, 18:57

Ok, about the STK replacement. I am just adding GameCenter :) Do you rename your stk? from lets say YourGame.stk to S3DMain.stk?

Now I created the app, start it up on the iPhone. Get the Login windows, now I tried to login with my apple account. It says that my game is not known to GameCenter. I enabled it in itunesconnect though?

What are the steps to enable it, and can you enable it while another version is being in review by Apple?

kind regards,

Markus
http://www.nifty-inspirations.com, because simple things are hard to find!
Markuzzzz
Platinum Boarder
Platinum Boarder
 
Posts: 578
Location: Netherlands

Re: Game Center integrated!

Postby vklymenko » 07 Mar 2011, 19:10

yes, Im renaming to S3DMain.stk : )
app-id also the same (in the xCode proj and on account, like com.mycompany.mygame)? if app id the same, check again enabling, it can be 2 actions: when you click on app in account and opening by button "manage game center"->Enable,
but also I saw "enabling" button on page, where you have game's description, categories etc.
User avatar
vklymenko
Platinum Boarder
Platinum Boarder
 
Posts: 758
Location: Europe

Re: Game Center integrated!

Postby dpharaoh » 07 Mar 2011, 19:22

The games are usually enabled by default, though it does take some time for itunesconnect to propagate stuff.
dpharaoh
Platinum Boarder
Platinum Boarder
 
Posts: 1519
Location: New Bedford, MA

Re: Game Center integrated!

Postby vklymenko » 08 Mar 2011, 12:08

btw I have only one issue for now with the integration: it works well on iphone, but in ipad's simulator (4.2) I see next:
- when I close a leaderboard for example screen doesn't want to receive any inputs anymore. I saw that before and the solution was
Code: Select all
[viewController.view.superview removeFromSuperview];

instead
Code: Select all
[viewController.view removeFromSuperview];

but even that seems not helping,
have someone experienced such issues?
User avatar
vklymenko
Platinum Boarder
Platinum Boarder
 
Posts: 758
Location: Europe

Re: Game Center integrated!

Postby Markuzzzz » 08 Mar 2011, 16:53

Hi,

I still have problems with enabling GameCenter.

I already have the game released for 2 years now. Now I want to add GameCenter to it, is this possible?
In iTunes I enabled the GameCenter option half a day ago, if I start up my game with your GameCenter code, the GameCenter login appears, I create a new account in a sandbox. At the end when it tries to login is says: "game not recognized by GameCenter", what am I doing wrong?

markus
http://www.nifty-inspirations.com, because simple things are hard to find!
Markuzzzz
Platinum Boarder
Platinum Boarder
 
Posts: 578
Location: Netherlands

Re: Game Center integrated!

Postby vklymenko » 08 Mar 2011, 17:06

Hi Markus!
I can try to help you by using some remote-control program like team-viewer, but sorry at least tomorrow. If that sounds good to you, write me plz at vklymenkowork@gmail.com and we will try to figure out ; )
User avatar
vklymenko
Platinum Boarder
Platinum Boarder
 
Posts: 758
Location: Europe

Re: Game Center integrated!

Postby Markuzzzz » 08 Mar 2011, 21:48

Ok, finally got it running in the simulator. This is what i needed to do, after implementing the source in this thread:

1) Checked my App ID for Game Center option in Provisioning Portal, usually enabled by default
2) Created new development profile using App ID in step 1.
3) Created new dummy version using 'add new app' and App ID from step 1.
3) Enable Game Center and one leaderboard in iTunesConnect
and then the most important step:
4) go to current version in the app information window and goto view details and at the bottom you will see: Game Center Enabled for this version, click so it goes green!!!
5) start simulator, goto game center sign out, you need to create a user for the sandbox
6) start app and login in with that user

et voila! It should roll...
http://www.nifty-inspirations.com, because simple things are hard to find!
Markuzzzz
Platinum Boarder
Platinum Boarder
 
Posts: 578
Location: Netherlands

Re: Game Center integrated!

Postby Markuzzzz » 09 Mar 2011, 08:15

Has anyone tested what happens if iOS < 4.1? How do I know in Lua when GameCenter is not supported?

kind regards

Markus
http://www.nifty-inspirations.com, because simple things are hard to find!
Markuzzzz
Platinum Boarder
Platinum Boarder
 
Posts: 578
Location: Netherlands

Re: Game Center integrated!

Postby vklymenko » 09 Mar 2011, 12:56

Hi Markus!
great,
you have 2 callbacks to handle is game center available or even if someone log out while playing:

so by default you should have a global variable in your scripts to know IS gamecenter or IS NOT:

onGameCenterLogged
onGameCenterOut

you have these handlers, and they are in scripts, so once someone open gamecenter/login, you will receive first one, in another case - second.
In this way you have control of GameCenter work/not in your scripts ; )
User avatar
vklymenko
Platinum Boarder
Platinum Boarder
 
Posts: 758
Location: Europe

Re: Game Center integrated!

Postby Markuzzzz » 10 Mar 2011, 08:41

Ok, so if a device doesn't support GameCenter (because iOS <4.1) the onGameCenterLogged will never occur. I think I have this coded properly now :) Scoring is implemented and working in the sandbox. Next step is to create achievements..

I have another interesting question concerning the GameCenter accounts. Is there a way to get the account name of the player from GameCenter? Would be nice to enter the players name. And also to check whether you are updating the right scores for the right user.

It might be possible someone starts a game with account A, leaves the game and logs in into gamecenter with another user account B. When updating the score of the pending game, the last account B is updated and not the first mentioned account A. How did you guys solve this problem?

kind regards

Markus
http://www.nifty-inspirations.com, because simple things are hard to find!
Markuzzzz
Platinum Boarder
Platinum Boarder
 
Posts: 578
Location: Netherlands

Re: Game Center integrated!

Postby vklymenko » 10 Mar 2011, 10:31

I haven't thinking about retrieving current player's name as far scores submitting automaticly to user, which is currently logged in,
but basicly it shouldn't be too hard to get current player's name:

there is a sample of how to retrieve top N scores/names from leaderboard at the end of the tutorial:
Code: Select all
- (void) fillMarkersTable

so there is a way to convert player's id/aliases, so what we need is just to know which ID we need, I think this should be a hint:

Code: Select all
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) {

so we can extract player's name from "localPlayer"
I haven't did this, but thats my first thoughts : )
User avatar
vklymenko
Platinum Boarder
Platinum Boarder
 
Posts: 758
Location: Europe

Re: Game Center integrated!

Postby miguel » 10 Mar 2011, 18:32

Hi all,

First of all, thanks a lot vklymenko for the tutorial. We have implemented the Game Center with success but we are having a problem when you send the achievement data. The game freezes for a few seconds when you send the achievement, if the time period isnt too long and you send another achievement this doesnt happen but if the time period is too long the problem appear again.

Any idea whats going on?

Thanks again.
User avatar
miguel
Expert Boarder
Expert Boarder
 
Posts: 121

Re: Game Center integrated!

Postby vklymenko » 10 Mar 2011, 18:38

hi! hm, I never saw such issue... maybe its something with local scripts - have you tried to trace/log the line where you're sending achievement (maybe its happening on frame change or something and its causing overload). Scores submitting works ok? achivements submitting should be the same thing. which device/iOS you are using for testing?
User avatar
vklymenko
Platinum Boarder
Platinum Boarder
 
Posts: 758
Location: Europe

Re: Game Center integrated!

Postby miguel » 10 Mar 2011, 19:50

Hi again vklymenko,

The problem still happen. When i test the game with the iphone emulator there isnt any problem, only when i try it with the iphone.

The scores submiting works perfect. We are testing with 2 iphones 4 (IOS 4.1 and 4.2) and an ipod 3g (IOS 4.1).

I'm starting to think it may be a problem of the Game Center service, now we arent having the problem with the same version in the iphone with IOS 4.2


Thanks Again.
User avatar
miguel
Expert Boarder
Expert Boarder
 
Posts: 121

PreviousNext

Return to Code Snippets