Game Center player photo

I’m working on some local networking in an app.  One device is a server and the other is a client.  Because I can assume both are iOS with Game Center, I am using the playerid to log onto the local server.  The server says something like: <Game Center alias> would like to join your server and it shows the appropriate picture.

At least, it’s supposed to, which leads to my problem.

I am using two test game center accounts with different pictures for this test.  Each device gets it’s own id and alias and sends it to the other device.  Because Corona SDK doesn’t actually give me the player image file, I have to request the image at the destination device using the forwarded id.

The problem is, Game Center won’t send the picture.  It says, “this application is not recognized by Game Center”.

My test app can log into Game Center on both devices, so… something recognizes it.  It is “sandboxed” but I don’t fully understand what Apple thinks “sandboxed” means.  I understand the concept but not the parameters of the implementation especially as it regards to Game Center.  

Is this a problem that will just go away when I publish?  Isn’t that unreasonable to expect me to ship with an untested feature?  Can Corona just let me get the player image on the sending device so I can send it to the other device?  I realize that I could just have the player store a duplicate image to be used with the game, but that seems needlessly fiddly.  The whole point of using Game Center is to allow the player to use their established gaming identity.

To summarize, both devices can log into Game Center, both devices connect successfully, Game Center won’t send the other player’s image because it says the application is not recognized by Game Center.

Any advice is appreciated.

As an experiment, I changed the code to load the local players image.  It doesn’t actually load the image of the local player either, however it does load a silhouette image that says “sandbox” across it.  Are all player images the same size?  If they are, I can use this image as my template for scale and placement.

BTW, the “small” image is gigantic and the “normal” image is even bigger.  I’m using the small image at a scale of .18 actual size to make it roughly 52x52.

If all images are not the same size, I’m going to have a problem.

(Edited to correct 1.8 to .18)

Hi Mark,

So to get the photo, did you use something like this? What format are the images you’re using?

[lua]

gameNetwork.request( “loadPlayerPhoto”,

    {

        playerID = “G:0123456789”,

        size = “Small”,  – “Small” or “Normal”

        listener = requestCallback

    }

)

[/lua]

Brent

Yes, that is the code I used.  It’s pretty straight forward stuff.  I tested it with both “small” and “large” and they return different sized images, but both sizes are enormous.  I’m testing on an iPhone 5 and an iPad 3.

I’m not sure what you are asking about image type, the request doesn’t return a file, it returns a display object.

The file I uploaded to Game Center as a gamer pic was a jpg, if that is what you were asking.

When I get the display object I add it to a display group along with a frame overlay that was a png (again, guessing what you are referring to).  The display group is at 1:1 scale.

Ok, I’ve got some more data but I’m not sure what it means.

To get the image to the appropriate size, I need a different scale on the iPad 3 vs the iPhone 5.  To make the image the appropriate size, I need a scale of .18 on the iPhone 5 and I need a scale of .09 on the iPad 3.  This suggests that I’m being sent a different file on each device.

I’m using the standard config file from your website:

http://coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/

I always just use that one because it says it’s the “ultimate” and that’s one less thing I need to do.

Hi Mark,

For the image you uploaded to GC, what was its size?

When the image gets returned, does it not obey the standard content size scaling at all? Do you display it using newImageRect()?

Thanks,

Brent

1024x1024. I’m testing and I just grabbed a unique image out of the camera file to be the tester image.  I just had to download it to see what size it actually was.

I just checked the Game Center app, for whatever reason the image I put in was replaced by the default “sandbox” silhouette.  I tried to change it back and it seemed to accept the photo because it shows the image in the little circle.  When I open my test app and request the photo, the app gives a fatal error.  When I went back to the Game Center app the image was changed back to the default “sandbox”.  Maybe I am not allowed to have an image with a sandbox account?  This whole sandbox system is very opaque it just seems to fail without feedback.

The default image obeys scaling, I’m scaling it as I said above.  If I use myImage.xScale, myImage.yScale = .09 .09, the image changes size.  But it is not consistent between devices.  Like… normally when I display an image with newImageRect, a 52x52 image takes up about the same amount of space on any device.  That is not what I am seeing in this case.

I’m not using newImageRect(), CSDK doesn’t give me the file, it gives me the display object.  I was looking through apple documentation and I see that the normal and small thing is the same in their documentation so I’m assuming CSDK is just passing it through.  Is that right?

Hi Mark,

I see what you mean now: since the photo is returned as one size (“small” or “large”), I think there are two options to handle it:

  1. Instead of scaling it, set its width and height directly, so it’s uniform to your content area.

–OR

  1. Detect the image suffix (display.imageSuffix) to determine which scale suffix is being used, and then conditionally use that info to scale the image to whatever size.

As for the sandbox issue, I don’t know what the issue is there (GameCenter is not my specialty). It wouldn’t surprise me if player images are not supported until the app is live in the market. Can you at least use the sandbox image for testing re: its size and where you display it on screen?

Brent

I used your first recommendation and got the result I wanted.  Thank you, I didn’t realize I could use .width and .height that way, I have always used them to retrieve the data, not set it.  I also didn’t realize they were subservient to the config file.

As long as the sandbox image is the same size as a player image I can use it for placement.  I was just looking for some assurance that if the sandbox image works then the player image would work.  I don’t like to ship on, “it will probably work”.

I didn’t know about display.imageSuffix, I will file that info away for another day.  

Is there a way to save the player image to the documents folder?  I suppose I could create the image and then use display.save on it… but that seems a bit hack-y.

Hi Mark,

Yeah, saving it to the documents folder would need to be done with display.save() or similar. It’s not really hack-y, since this kind of thing is fairly routine when dealing with saving images from the screen. :slight_smile:

Brent

As an experiment, I changed the code to load the local players image.  It doesn’t actually load the image of the local player either, however it does load a silhouette image that says “sandbox” across it.  Are all player images the same size?  If they are, I can use this image as my template for scale and placement.

BTW, the “small” image is gigantic and the “normal” image is even bigger.  I’m using the small image at a scale of .18 actual size to make it roughly 52x52.

If all images are not the same size, I’m going to have a problem.

(Edited to correct 1.8 to .18)

Hi Mark,

So to get the photo, did you use something like this? What format are the images you’re using?

[lua]

gameNetwork.request( “loadPlayerPhoto”,

    {

        playerID = “G:0123456789”,

        size = “Small”,  – “Small” or “Normal”

        listener = requestCallback

    }

)

[/lua]

Brent

Yes, that is the code I used.  It’s pretty straight forward stuff.  I tested it with both “small” and “large” and they return different sized images, but both sizes are enormous.  I’m testing on an iPhone 5 and an iPad 3.

I’m not sure what you are asking about image type, the request doesn’t return a file, it returns a display object.

The file I uploaded to Game Center as a gamer pic was a jpg, if that is what you were asking.

When I get the display object I add it to a display group along with a frame overlay that was a png (again, guessing what you are referring to).  The display group is at 1:1 scale.

Ok, I’ve got some more data but I’m not sure what it means.

To get the image to the appropriate size, I need a different scale on the iPad 3 vs the iPhone 5.  To make the image the appropriate size, I need a scale of .18 on the iPhone 5 and I need a scale of .09 on the iPad 3.  This suggests that I’m being sent a different file on each device.

I’m using the standard config file from your website:

http://coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/

I always just use that one because it says it’s the “ultimate” and that’s one less thing I need to do.

Hi Mark,

For the image you uploaded to GC, what was its size?

When the image gets returned, does it not obey the standard content size scaling at all? Do you display it using newImageRect()?

Thanks,

Brent

1024x1024. I’m testing and I just grabbed a unique image out of the camera file to be the tester image.  I just had to download it to see what size it actually was.

I just checked the Game Center app, for whatever reason the image I put in was replaced by the default “sandbox” silhouette.  I tried to change it back and it seemed to accept the photo because it shows the image in the little circle.  When I open my test app and request the photo, the app gives a fatal error.  When I went back to the Game Center app the image was changed back to the default “sandbox”.  Maybe I am not allowed to have an image with a sandbox account?  This whole sandbox system is very opaque it just seems to fail without feedback.

The default image obeys scaling, I’m scaling it as I said above.  If I use myImage.xScale, myImage.yScale = .09 .09, the image changes size.  But it is not consistent between devices.  Like… normally when I display an image with newImageRect, a 52x52 image takes up about the same amount of space on any device.  That is not what I am seeing in this case.

I’m not using newImageRect(), CSDK doesn’t give me the file, it gives me the display object.  I was looking through apple documentation and I see that the normal and small thing is the same in their documentation so I’m assuming CSDK is just passing it through.  Is that right?

Hi Mark,

I see what you mean now: since the photo is returned as one size (“small” or “large”), I think there are two options to handle it:

  1. Instead of scaling it, set its width and height directly, so it’s uniform to your content area.

–OR

  1. Detect the image suffix (display.imageSuffix) to determine which scale suffix is being used, and then conditionally use that info to scale the image to whatever size.

As for the sandbox issue, I don’t know what the issue is there (GameCenter is not my specialty). It wouldn’t surprise me if player images are not supported until the app is live in the market. Can you at least use the sandbox image for testing re: its size and where you display it on screen?

Brent

I used your first recommendation and got the result I wanted.  Thank you, I didn’t realize I could use .width and .height that way, I have always used them to retrieve the data, not set it.  I also didn’t realize they were subservient to the config file.

As long as the sandbox image is the same size as a player image I can use it for placement.  I was just looking for some assurance that if the sandbox image works then the player image would work.  I don’t like to ship on, “it will probably work”.

I didn’t know about display.imageSuffix, I will file that info away for another day.  

Is there a way to save the player image to the documents folder?  I suppose I could create the image and then use display.save on it… but that seems a bit hack-y.

Hi Mark,

Yeah, saving it to the documents folder would need to be done with display.save() or similar. It’s not really hack-y, since this kind of thing is fairly routine when dealing with saving images from the screen. :slight_smile:

Brent