Possible to initialize an FlxState with different data for each level? #2477
-
Hi! I'm making a little puzzle game to exercise myself with HaxeFlixel. Please forgive what may be a very basic question. I have looked through the docs but I haven't found any hints there. Is there a recommended way to pass extra data to an FlxState when I'm switching to it? If so, how could I do this? The HaxeFlixel docs warn against overriding the FlxState constructor, so I've purposefully avoided doing that. The reason I want to do this--I have my puzzles defined as JSON resources, and I'm hoping to be able to load up a specific puzzle into the PuzzleState as needed. Thanks for your time! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I guess the answer to this question depends on how you're loading up your FlxStates.
FlxG.switchState(new LevelOne(argument1, argument2)); Then you can load the arguments into your class constructor.
|
Beta Was this translation helpful? Give feedback.
I guess the answer to this question depends on how you're loading up your FlxStates.
FlxG.switchState
. You can pass arguments into your level like this:Then you can load the arguments into your class constructor.
Happy to explain more if it doesn't make sense.
#2400