AJAX - Download as binary file

Get help using Construct 2

Post » Mon Jan 27, 2014 1:15 am

Hello again! I have attempted to create an auto-updater for my game 'ROCKETS EVERYWHERE', and so far everything is responding correctly, until I finish downloading a file (like a .zip or a .png) and it's corrupt; full of unrecognizable characters.

Based on minimal research, it turns out that javascript variables store info as ASCII and it can't recognize most binary characters used.

Is there a way to get AJAX to download as Binary and not ASCII or Unicode? If not, is there a way around this problem?
B
29
S
7
G
5
Posts: 202
Reputation: 5,310

Post » Mon Jan 27, 2014 2:03 am

Doable yes, but not naturally in C2 right now and I can't imagine will be real soon. You can try the Base64 plugin in the plugins section of the forum.

However what you are looking for are these
ToBase64 which is done prior to AJAX sending
ToBinary which is done once you received the AJAX parts of the fine.

http://www.base64decode.org/
maybe some where here will have some tools where you can make an Encode and Decode plugin for data files.
B
92
S
18
G
9
Posts: 2,455
Reputation: 15,113

Post » Mon Jan 27, 2014 2:44 pm

Interesting. I'll mess around with base64 encoding/decoding and see if it does anything different. I think the Extra Expressions plugin has this built-in, which is nice. :)

Thank you again!
B
29
S
7
G
5
Posts: 202
Reputation: 5,310

Post » Mon Jan 27, 2014 3:57 pm

Web games auto-update by themselves so you shouldn't have to make your own updater. More in this tutorial: https://www.scirra.com/tutorials/70/offline-games-in-construct-2
Scirra Founder
B
402
S
238
G
89
Posts: 24,637
Reputation: 196,071

Post » Mon Jan 27, 2014 5:07 pm

This looks very useful, but after reading it, I realized that this is for web-based apps. I feel embarrassed about not mentioning this to start with, but I'm distributing the game via Node-Webkit.

Is it still possible to use this functionality when native, or no? I noticed there is no trace of an offline.appcache file, so I'm assuming no. Either way, I appreciate the help and I'm really enjoying Construct 2. :)
B
29
S
7
G
5
Posts: 202
Reputation: 5,310


Return to How do I....?

Who is online

Users browsing this forum: dop2000, Google [Bot] and 4 guests