[Creator 3.8.2]
Hey there,
I’m making a sport the place customers create their very own platformer ranges and I used to be questioning whether it is doable to export information in-browser and skim values from information on a participant’s laptop. This type of performance could be wonderful, as it might enable level-sharing between creators.
How would possibly I create an “export stage” button which, when pressed, exports a .txt file to the person’s downloads folder? Additionally, is there a option to learn information from the identical file from any listing on the person’s laptop into the sport, to be saved as a cookie in-browser? I solely have to learn the information from the file, not reserve it as an asset in-game.
Lastly, is there a correct option to flip any type of information (particularly a string) right into a textual content file just like the one described above?
I do know these are plenty of questions, however any assist could be extraordinarily useful to me! I’ve spent a number of hours trying however haven’t discovered something helpful but. If somebody may give me a working reply to all 3 questions, they’ll obtain a point out within the credit of my sport.
Additionally, if a mod is studying this, is it doable to have my username modified? I’m reachable by DM
Bump – This query is pivotal to my sport’s success, if anybody who’s studying wants clarification on my query (shouldn’t be obligatory imo) and would possibly probably be capable of give a solution, please attain out to me!
On the net, you can not actually learn information from the participant’s laptop. The browser is a self-contained sandbox, it doesn’t have the system context, solely the browser context.
Whereas Cocos doesn’t present a file system for such circumstances, if you’re working with solely an internet platform in thoughts, you possibly can attempt to use Internet APIs to entry the browser file system → De File System Entry API: vereenvoudigt de toegang tot lokale bestanden | Capabilities | Chrome for Builders.
Create and Save textual content file in JavaScript?
Nonetheless, you continue to might want to determine learn such .txt information in Cocos area. For that, I consider the better means could be to have a server the place the customers might add the .json / .txt information after which your sport might react to such new uploads utilizing an HTTP or Internet Sockets connection
For “cookies” primarily based information, you should utilize the localStorage API and work with textual content values → Person Information Storage | Cocos Creator
Since you aren’t contemplating App Retailer releases, I might say that Sizzling Replace tunnel can also be a chance → Property Sizzling Replace Tutorial | Cocos Creator