Locking Levels

KempProductionsKempProductions Member Posts: 139
edited November -1 in Working with GS (Mac)
I know this has been asked before, but I searched through the forums, and I couldn't find it where I had seen it before. But I need help being able to lock a level in a "Level Selection" scene. And also putting a padlock or something over the Level image when it is locked.

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    You'll need to keep track of a global game attribute (integer) called something like "currentUnlockedLevel". Set it initially to 1 (because the first level is usually unlocked)

    Then create a padlock actor. Drag a copy of this actor on top of all of your level select buttons.

    Create an integer attribute inside this actor called "myLevel". Leave it at 0.

    Create a Rule in the padlock actor like this:

    Rule
    When game.currentUnlockedLevel >= self.myLevel
    Destroy

    Then, in each of the instances of the padlock on the stage, double click on it and edit the myLevel attribute to be the appropriate number.

    The buttons themselves will need a similar setup.

    A myLevel attribute and a rule:

    Rule
    When game.currentUnlockedLevel >= self.myLevel
    Go to Appropriate Scene
  • KempProductionsKempProductions Member Posts: 139
    Hmm. Its not working.

    I have a global integer game attribute set to 1.
    I have my "Locked" actor, with a integer attribute 'myLevel' set to 0. Then a rule in that actor like you said.

    But when i preview, that "Locked" actor doesn't show up.

    Doesn't there need to be something in each scene?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    you need to set the myLevel attribute on each lock instance in the scene...
    double click on each lock to set it
  • KempProductionsKempProductions Member Posts: 139
    The lock actors are all in one scene, the scene selector, and they are on each button that takes you to a certain level.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    yes, i realize that - you need to double-click on each one and set the myLevel attribute to the appropriate number.
  • KempProductionsKempProductions Member Posts: 139
    Ok firemaple, I got them to lock. How do I get them to unlock though? And to stay unlocked when you exit the game and then go back to it another day?
  • KempProductionsKempProductions Member Posts: 139
    Nevermind, I got them to unlock, but I still don't know if there is something I have to do where if you exit the game, then the next time you play, those levels will still be unlocked. Do I need to just 'Save Attribute'?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Whenever the attribute currentUnlockedLevel changes, you need to save it, like this:

    Save Attribute
    game. currentUnlockedLevel To Key: CURRENTUNLOCKEDLEVEL

    Then, on the very first scene in the game, BEFORE the level select screen - Ideally on a scene that only appears once, like a splash screen, or your logo scene - you use the load attribute behavior, like this:

    Load Attribute
    game. currentUnlockedLevel From Key: CURRENTUNLOCKEDLEVEL
  • KempProductionsKempProductions Member Posts: 139
    Thank you very much! Now I can focus on making levels.

    I didn't realize my game was similar to Danger Cats! , now people will compare mine to yours, so I don't know how good mine will do, because your game is amazing.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Thanks!
    Well, they are both based on Totem Destroyer and similar games...
    I just wanted my game to have a slightly different theme, so it would stand out from the crowd...
  • KempProductionsKempProductions Member Posts: 139
    Yeah, i see. Your graphics are just so much better than mine, which also stands out.
Sign In or Register to comment.