loadPlayerPhoto Corona Stupidness

Hi Coronalabs,

I’m having an issue with your loadPlayerPhoto implementation. What is your motivation for returning a displayObject as the event.data.photo? What we need is the binary data, either as a replacement or as an extra value. Something that can be saved to disk without any hassle.

If you play for instance 10 matches against the same opponent and you show them in a tableview, there will be 10 rows. To be able to show the opponent image on all the rows, we have to loadPlayerPhoto 10 times. If we instead had it saved on disk it would be just 1 network roundtrip.

If the game has 2 tabs - “My turn” and “Opponent turn”, it gets even worse. The normal thing to do when the tabs are switched is to remove the old tableview and create a new one with the correct data. But display.remove(tableview) will also remove the photo display objects. Which means we’ll have to issue another 10 network roundtrips to get new copies of the photos.

If you only supported cloning of display objects your implementation of loadPlayerPhoto would be OK. As it is now, it just stinks.

You’ll probably suggest to flash the loaded photo on the stage, save the displayObject group to disk and then use that. And that is probably what we’ll end up doing, even if it will look really unprofessional with the flashing. But it does not make up for the loadPlayerPhoto Corona Stupidness…

Or do you have any better solutions? How about adding event.data.binaryphoto to the table data, that would be valuable for everyone using your product.

What is “loadPlayerPhoto” part of?  I don’t see it in the core APIs?

http://docs.coronalabs.com/api/library/gameNetwork/request.html

The photo doesn’t have to be shown on screen to save the group to disk - I think you can load it into a temporary display group, save the group and immediately remove the image and group before it’s actually shown on screen.

Nick’s idea seems rather reasonable.  The other thing is that I don’t know what caching Apple is doing under the hood.  Perhaps they are already saving it for you and future calls just load it from local storage.  You have to have a display object to show it so this maybe the simplest way to go about it. 

Rob

Hi,

yes, it works fine like this

display.save(event.data.photo, playerID … “.png”)

native.setSync( playerID … “.png”, { iCloudBackup = false } )

event.data.photo:removeSelf()

event.data.photo = nil

But I still don’t like that you return displayObjects for images, it would be a lot better if you could honor binary data. This goes for several of your APIs

What is “loadPlayerPhoto” part of?  I don’t see it in the core APIs?

http://docs.coronalabs.com/api/library/gameNetwork/request.html

The photo doesn’t have to be shown on screen to save the group to disk - I think you can load it into a temporary display group, save the group and immediately remove the image and group before it’s actually shown on screen.

Nick’s idea seems rather reasonable.  The other thing is that I don’t know what caching Apple is doing under the hood.  Perhaps they are already saving it for you and future calls just load it from local storage.  You have to have a display object to show it so this maybe the simplest way to go about it. 

Rob

Hi,

yes, it works fine like this

display.save(event.data.photo, playerID … “.png”)

native.setSync( playerID … “.png”, { iCloudBackup = false } )

event.data.photo:removeSelf()

event.data.photo = nil

But I still don’t like that you return displayObjects for images, it would be a lot better if you could honor binary data. This goes for several of your APIs