How do I download file/image in C2 file folder ?

Get help using Construct 2

Post » Wed May 06, 2015 9:58 am

Hi!

I'm wondering if it's possible to download images into C2 file folder.

The mechanic is:

From a C2 game (wrapping in Android apk with XDK)
->Download image files from server
->Save into file folder of C2

Then, when the game need it:
->Sprite -> Load Image from URL: "ID_IMAGE.jpg"

Maybe it's possible to save image from sprite into file folder, during the game ?
If it would be possible, I can do this:

-> Sprite -> Load Image from URL: "http://www.server.com/ID_IMAGE.jpg"
-> Save img from sprite into c2 file folder
Then: Sprite -> Load Image from URL: "ID_IMAGE.jpg"
B
18
S
4
Posts: 83
Reputation: 2,083

Post » Mon May 11, 2015 1:42 pm

rexrainbow said: Sorry, I had no idea about that, you might try ask to @cranberrygame .


cranberrygame said: You can use following plugin.
Phonegap FileTransfer: download or upload file to your server. (http file download and upload)

see more: https://plus.google.com/102658703990850 ... QceTB8MGfs


@cranberrygame, thanks for your answer,

What I want is not to transfer a file on a server, but put the images in a C2 "cache", in order to not download it again if they are in the app cache.

I see the function "Phonegap File: read, write file.. get directory entries and create directory...".
Isn't it possible to make a "cache" with this one ?
Where is it possible to write file and directory ?
B
18
S
4
Posts: 83
Reputation: 2,083

Post » Mon May 11, 2015 2:14 pm

@amkp

You can also check file exists or not by using Phonegap File.Check if file exists action.

Thanks
Sang Ki Kwon
Construct2 Cordova Plugins (currently 87 plugins): https://www.scirra.com/store/construct2 ... ugins-1662

Construct2 Prototype Capx (currently 50 capx): https://www.scirra.com/store/games-with ... -capx-3088

Home page: http://cranberrygame.com
B
65
S
22
G
81
Posts: 780
Reputation: 46,631

Post » Mon May 11, 2015 3:18 pm

This tutorial I wrote might just help https://www.scirra.com/tutorials/1457/s ... os-android
I explain how to save an image (in this case a screenshot) using webstore. And with a bit of tinkering it should be able to fit what your after.
Need help finding the right look for your game? I can help! hayes2D.com
B
28
S
5
Posts: 173
Reputation: 2,126

Post » Mon May 11, 2015 4:29 pm

Thanks @0Hayes,
Your tutorial is a good idea.

But I have doubts about using the webstorage in this case.

Webstorage is size limited, I don't remember how much.. maybe, 5Mo ?
The image is surely stocked in Base64 type, who has superior size than file format.

So, for one image that's maybe ok, but for hundreds of images, I think that's impossible...
B
18
S
4
Posts: 83
Reputation: 2,083

Post » Tue May 12, 2015 1:39 pm

Yeah, its pretty limited with the save if I remember correctly. Sorry I couldn't help, will give it some more thought though. Good luck!
Need help finding the right look for your game? I can help! hayes2D.com
B
28
S
5
Posts: 173
Reputation: 2,126


Return to How do I....?

Who is online

Users browsing this forum: Mayfly and 8 guests