Skip to content

How should I go about unlocking characters? #2504

Answered by RichardBray
aflacc asked this question in Q&A
Discussion options

You must be logged in to vote

This is a good question but I guess more of a general game dev question than a HF specific one. Does your game support saving or not?

If it supports saving then you can just use FlxSave to store an object of data:

{
  'characterOneUnlocked': true,
  'characterTwoUnlocked': false,
}

I would not suggest having using nested objects in FlxSave as I've had bad results with this, instead, I would say you should use a string of 1s and 0s

{
  'unlockedCharacters': '1, 0'
}

and then turn that into an array.

If your game doesn't support saves then you could store everything in a singleton that all the states in your game would have access to. I have a tutorial on how to do that here, although it'…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aflacc
Comment options

Answer selected by aflacc
# for free to join this conversation on GitHub. Already have an account? # to comment
Category
Q&A
Labels
None yet
2 participants