简体   繁体   中英

How to read and write from text file in an HTML5 Javascript Canvas Phonegap game?

I'm developing a game in HTML5 Canvas using phonegap and was wondering how to implement a "save game" and "load game" functions to a local text file, which are cross platform to both Android and iOS? Thanks!

**Kind of like the fstream in C++.

您可以将WebDatabase用于此目的。

A better approach is to store the player's progress on the server side. This way you can avoid the player having to restart the game from the first level if they clear or lose the application data.

Also, it gives the flexibility to play your game across multiple devices with the same progress - Android, IOS, Phone, Tablet,etc...

If not consider backing up player's data and implement a restore mechanism.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM