开发者

How to create, open, save and close a file or directory in javascript?

Is there a cross-pla开发者_如何学编程tform way to do these actions? Or only open files, the user download the files. I want to make a mmo side-scrolling game, and it needs to save maps, sprites and musics.


It's not possible to access the local filesystem at the client's side. If your data is text (image -> text through base64 data uri's), the DOM Storage may be interesting for you. The files must be base64-encoded at the server's side, though.

References:

  • https://developer.mozilla.org/en/data_URIs
  • https://developer.mozilla.org/en/DOM/Storage


JavaScript has no I\O capabilities by itself.

If you want to reduce the traffic use the model in Travian:

  1. the user can save all of the resource files needed to his PC, device etc;
  2. the user submits to the server the path, where the resource files are saved;
  3. the game generates custom css with localpath (the path to the files on his machine).

This will reduce the traffic enormously.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜