Best way to make global variables
Is there a convention in how to store global variables? current level, statistics, and all that?
I figure a lot of ways to do it, I'd like to stick to the haxeflixel convention if there is one.
Looking at the demos, most of them seem to have a class called
Reg.hxand store those variables as
I think those are mainly the older demos like flappybalt, mode and minimalistTD, where
Reg.hxwas created automatically by flixel-tools - so don't feel enforced to use that name.
I use the Reg option and if it is something I want to keep between sessions I will Reg with FlxSave
Personally, I use a
Game.hxfor that. I split game mechanics into classes and put them into a
Game.hxthen create them at the start of the game. (Something like singleton even though that it's not recommended but it's pretty clean and works for me)
@MegaLeon you can also use inline public static to make them read only
Personally I have my own registry class called Constants.hx
inlineonly works for basic types. You can use
(default, null)(read-only outside of this class) properties for the rest.