Thanks to @Naomi’s guidance I managed to get 2 sandbox users to friend each other and completed one successful match. The GC integration is very unreliable though. Not sure if this is because the sandbox is slow and unresponsive etc. Now that it is working to a degree I will try and see how it does what it does. Thanks for all the guidance.
No problem at all, @ksan. I’m sure we’ll share more as we proceed with this.
There’s one thing I’d like to note. I spent a lot of time reading the API doc, looking for an API that would always open up the GC screen for starting a new game either via auto-match or invite-friend. I could not find it, and it truly frustrated me. But after pulling my hair, I decided I’d just experiment instead of trusting the doc literally, and I found that playerIDs noted as “required” is not necessarily required (or at least not including it did not trigger errors or crash my app):
- gameNetwork.request(“createMatch”, { listener = roomListener, minPlayers = 2, maxPlayers = 2 })
– this automatically opens GC screen for starting a new game (either via auto-match or inviting friends)
- gameNetwork.show(“matches”, { listener = roomListener, minPlayers = 2, maxPlayers = 2 })
– if the user has never played a match game, it shows the same thing as the #1 above, but once a user starts at least one match game, it brings up GC screen that displays ongoing and/or completed game.
- gameNetwork.show(“createMatch”, { listener = roomListener, minPlayers = 2, maxPlayers = 2 })
– I think it behaved similar to (if not the same as) #2 above.
Maybe this finding will help you waste less time.
Naomi
@ Naomi, thank you very much for your continued sharing. These are very valuable insights. I got better results playing 2 iPhones both with IOS 6.1.3 against each other. When one of the match parties is on IOS 7 things seem a little less balanced. Not sure if this is related to IOS 7 issues or Corona SDK shortcomings or the way the sample is created. There is so much to learn. Thanks for all your help.
@ksan, you are welcome, and thank you for sharing your experience doing match game between iOS7 device and iOS6.1x device. I’ll keep that in mind. (I haven’t updated my devices to iOS7 yet, so I’ll just have to wait until I’m ready to see how it performs.)
Thanks again.
Naomi
Anyone wanna be my GameCenter “sandbox” friend send me an invite to lano78. I’m doing a custom interface so I need as many as possible.
Thanks.
Sandbox friend request sent.
Naomi, thanks for this information. Do you know by any chance, how i can submit customData to the match (when creating it)? I simply have two different game modes, and the player that accepts the challenge need to know that.
maybe i am just blind?
thanks!
Hi Dingo,
I haven’t looked at the code for a while, but here’s what I’ve done when sending my game specific data to game center for the opponent using gameNetwork.request:
[lua]
– when the first player creates the game and ends his/her turn
gameNetwork.request(“endTurn”,
{
nextParticipant = { myOpponent },
matchID = myGameID,
data = myData – json encoded data string
})
– after the opponent finishes his/her turn
gameNetwork.request(“endMatch”,
{
matchID = myGameID,
data = myData, – json encoded data string
outcome = myOutcome
})
[/lua]
I hope this helps.
Naomi
Naomi, thanks for your answer. But I guess you’re calling createGame beforehand, right? Or does endTurn create the game too? I guess not?
thanks!
Hey, Dingo, I createMatch. It creates ID for the game, identifies the host and number of players to be allowed in the game – but not the game data specific to my game.
The host player creates the custom game data after the match game ID is created and upon starting the game. When he/she completes his/her turn, he/she sends all game data that the opponent would need. The opponent would pick up the game specific data from game center when taking his/her turn.
That’s how I set up mine anyhow. I hope this makes sense?
Naomi
that’s how i am doing it right now, thanks for your answer!
No problem. Good luck with your implementation!
Naomi
Thanks! I just have one more question… i am loading the players with pictures in the title screen, where you select your opponents. after each game, i am back at that screen. can i cache the profile pictures, or do you dump them? How are you doing this?
Also, when i am loading the picture from gamecenter, it always appears on top, no matter what alpha and position i give it…how can i prevent that?
thanks :=)
You know, Dingo, you can probably do this because you use Enterprise version (or maybe because its an iOS version.) With Pro version, I am unable to get at the profile picture. Or at least for GPGS version. I actually asked about it when I worked on GPGS multiplayer game (before working on Game Center version) because I wanted to show the profile pictures of the players at the start of each game as well as the end of the game, but I was told it cannot be done. And after that, I didn’t look into getting the profile picture for iOS version.
Naomi
hi naomi, i am not using enterprise version right now for this build, and i can fetch the picture of friends (on iOS).
function gameCenterWrapper:loadPlayerPicture(player, callback) local requestCallback = function(event) callback(event.data); end gameNetwork.request( "loadPlayerPhoto", { playerID = tostring(player.playerID), size="Small", -- "Small" or "Normal" listener=requestCallback }) end
but as you mentioned, this works for iOS only i guess.
Thanks, Dingo. That sounds great. If we can do the same with GPGS, maybe I’ll consider adding this to both iOS and Android versions. If you plan on doing the Android/GooglePlay version, please let me know how it goes. It could be that Corona now offers this option.
Naomi
I’ll try to implement it with GPGS after the iOS release. Will let you know!
funny thing: when i call endMatch, it does not work, only when i call quitMatch (then the game has the state ended).
anyone else experiencing this? or do i need to endTurn first, and then call endMatch, instead of directly calling endMatch?
thanks for the help!
maybe someone can tell me if this is correct?:
player 1: createMatch
player 1: endTurn
player 2: endMatch
does player 2 need to call endTurn too?
can only the player that created the match end the match?