Allow gamer to upload an image : is it possible ?

Get help using Construct 2

Post » Fri Jun 28, 2013 2:38 pm

Hi guys, I would like to do this feature my game :

1) User can upload an image (it could be entering an URL to an image)

2) Game load the image into an existing sprite.

3) Sprite is saving loaded image (2) so if the game is restarted, the image don't have to be reloaded from internet.


I have test step 1) et 2) using Load image from. But I don't know how to do the 3). Anyone has idea ? I would like it to work if possible on mobile too (I'm using cocoonJS)

ThanksOron2013-06-28 14:40:20
B
4
Posts: 12
Reputation: 649

Post » Fri Jun 28, 2013 3:16 pm

This would mean a change of constructs files, I dont think this works.

If there is a way, you have to overwrite the existing image on the user device or change the c2 file.

Im really not sure if this is possible at the runtime.

You could save it on the device, and write the path in a cache. This would save the user from downloading it again.
B
15
S
6
G
6
Posts: 512
Reputation: 5,555

Post » Fri Jun 28, 2013 3:30 pm

Like Darklinki said, changing the project files during runtime seems... dangerous ?
Most of all, if this is a webapp, modifying the project would modify it for everyone.
I can think of a way, not sure it will work with every image though.
What you need is the content of the image you load. So you have to load the image with an AJAX request, and save the lastData. Then, load the image from URL (AJAX.lastData). Don't put it only in the sprite, save it in one of the sprites variable, so it will be included in the savefile (making it a lot bigger though). On load finished, then Sprite : load image from URL (sprite.myvarible) should then bring back the image.
B
17
S
8
G
4
Posts: 461
Reputation: 6,077

Post » Tue Jul 02, 2013 6:20 pm

thank you for your answers, I'm going to try that.
B
4
Posts: 12
Reputation: 649

Post » Tue Jul 02, 2013 7:12 pm

it's possible via plugins, search on the plugin list, on the plugin side of this Forum...
ImageImageImageImageImageImage
Image
B
98
S
21
G
16
Posts: 1,338
Reputation: 21,152

Post » Tue Jul 02, 2013 8:33 pm

I had actually built this feature for a guy using c2. It was basically a php file that uploaded the picture to the server. The ajax call was made with the picture string and encoded/saved and in this case uploaded to Facebook. Look on stack exchange for example php code then use the ajax in c2 to transmit the picture. What you would want to do is name the file based on user unique I'd ie player1.jpg to you know when they log in you can load image via URL by just throwing their userid and jpg.

Long story short it is possible but it may be beyond the average users level of experience.
www.h1k3.tech

We are here for you!
B
76
S
22
G
15
Posts: 708
Reputation: 15,958


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests