B6ka Posted May 2, 2014 Share Posted May 2, 2014 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 Quote Link to comment Share on other sites More sharing options...
marvster Posted May 6, 2014 Share Posted May 6, 2014 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. Quote Link to comment Share on other sites More sharing options...
ultimatematchthree Posted May 16, 2014 Share Posted May 16, 2014 If it's just constants (meaning, they never change), then the way you did it in AS3 should still work fine in TypeScript, see for example http://stackoverflow.com/questions/22991968/public-static-const-in-typescript Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.