Hi folks,
I’ve tested de xml save and load for local games. So, ok, it works great!
Than I’ve tested de Json with webstorage, and parsing some data to a variable. So… ok too.
But, I have a doubt about how the Json file will work with multiple users. For example, to create a HTML5 game I need to use a webstorage to save and load(not a local file with xml, but a Json file on a host ), but Let’s supose the game will have thousands of downloads, and every user saves and loads ( json and webstorage). So, here comes the question:
What’s the best way to storage those multiple users saves and loads? Shold be createad an incremental json file name for each user( in this case I’ll have thousands of different json files in the host )? Or only one json file with diffents users Ids( but in this case witch should be the best way to parse loaded data)?
If you use the standard actions to save data, the data will be saved in the webbrowser webstorage which is on the user’s computer. So you can keep the same name, you don’t have to care where the storage is done.
No, the save/load actions of HTML5 use webstorages which are not the content of the website. The webstorages is a small storage in the webbrowser, not in your website. So, you can’t load a file from your website using those actions.
You speak about the first action of the screenshot ? It should work in both cases because you download the file from your website even when previewing locally. But I can’t see the whole action in your screenshot because of the panel in front of it.
EDIT : what does VariableString("") mean ? (First action)
Yes, it was wrong. I’ve changed and tested again, reading step by step the wiki page about json file load.
Again, it works beautiful for a native game preview, but for html5 (as you can see following the url ) nothing apears. Very strange.
I’ve tested with local parameters( without filling in the full url), as mentioned in the wiki, and again, filling in the full url to the file. Both ways works for a native game, but none of then to the html5 version.
I do not know if others have already tested or used this resource, but I really tried a lot, with many different options.
I’ve found the problem. JS request can only be done on url from the same server (if not, the request is rejected).
So, to make it work, you should try to remove the first parameter from your request (the server will be the current one).
The problem is that it won’t work when previewing but only when testing on the real server.
(Currently investigating how to do cross-domain requests)
The problem is on the server’s side.
You need to add some lines to your server’s .htaccess file :
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
(You can add this to the root .htaccess or to the testegame2 folder’s .htaccess)
PS : With that, you don’t need to remove your domain from the request in GD (it will work when previewing).