Jump to content

Best way to save and get game constants


B6ka
 Share

Recommended Posts

Hi,

 

I am new to Phaser and JS/TS. I am migrating from Flixel. I am using Typescript and testing the framework from Photonstorm's tutorial. In Flixel/AS3 I usually create a class (Assets.as) with game constants as public properties. I would like to ask what would be the best way to save and get game constants such as player movment speed, gravity, etc.

 

Best,

 

B6ka

Link to comment
Share on other sites

I just would attach your assets to this.game and store them with localStorage:

this.game.assets = {movement: 0, gravity:0, etc: ''};//savelocalStorage.setItem('savegame',JSON.stringify(this.game.assets));//loadthis.game.assets = JSON.parse(localStorage.getItem('savegame'));

Just take care cyclic object values while serializing.

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...