Search the Community
Showing results for tags 'game load'.
-
Hi, I've been working on my game project clicker (helps me learn JS and other languages). So it is going smooth so far. Thought it might be a good idea implement a save/load feature now. The following has no errors, but loading it has no effect. INITIAL VARS var player = { name:"", level:0, gold: 190,// CHANGE BACK TO 0 AFTER TESTING artifact: 0, weaponId:0, weaponLevel:0, spellId:0, spellLevel:0, goldPerClick:5, goldPerSec:0, currentTrainer:0, }; SAVE STATE /* SETUP A SAVE STATE */ function save() { // TRY TO SAVE THE GAME try { localStorage.setItem('copperSave',JSON.stringify(player)); }catch(err) { console.log('Cannot access localStorage - browser may be old or storage may be corrupt') } console.log('Game saved successfully'); }// FUNCTION: SAVE GAME LOAD STATE /* LOAD PREVIOUS game */ function loadGame() { var gameLoad = JSON.parse(localStorage.getItem("copperSave")); player= gameLoad.player; console.log(player); // this shows the starting vars NOT the saved var from getItem! } SOME MISC VARS TO HELP DEBUG initGame(); var answer = confirm('Continue from previous saves?\nWarning, "Cancel" creates a new game wiping previous saves'); if ( answer ) { loadGame(); } console.log('here after load query'); // GAME LOOP FOLLOWS BELOW.... It looks right, can anyone suggest why it might not be loading correctly. It just gives the starting variable, not the saved variables.
- 5 replies
-
- javascript
- game save
-
(and 1 more)
Tagged with:
-
on the iPad Air I've got the previous version of the CocoonJS launcher, everything works fine. On my other iPad I've got the new version (Updated a few days ago). The same game won't show up in the new Version. It shows FPS, but a black screen, there are also no errors in the console... I do not know what this is causing? any suggestions, what is different in the new launcher? //EDIT: Game won't show up in canvas+, webview+, webview. canvas+ loads the fps up to 60... that's all, webview+ and webview are doing nothing... still no errors in the console... before the update everything works fine. And it is not only with one game, another I've been developing : sam effect :/