phaser-typescript-template
phaser-typescript-template copied to clipboard
Global variables
Hello! I love this template, thank you for it, but I have a question about global variables... How I can have a variable for all states, like config (music on/off, number of players...)? I'm a newbie in typescript, and I have tried to do it in many ways but always have an error on compilation time.
Thanks a lot again!
Did a couple quick searches and didn't find a good way to do it. I think it is discouraged in TypeScript. One way you could accomplish this is by bundling all those related properties into a class and then pass that between the states. This forum post shows how you can pass additional parameters when "starting" a state. You might need to work around issues with TypeScript complaining about the extra parameters though, I'm not sure.