How can I keep instance variable from a non-global sprite?

0 favourites
  • 3 posts
From the Asset Store
Global plugin that allow for relatively easy and efficient implementation of an in-game inventory system
  • Hey, I have this map selection screen with the same sprite over 30 times, when pressed it goes to the level if instance variable locked = 1, if its 0 it doesn't do anything.

    In each level when finished, like enemy killed, I collect an inst. variable from that enemy to a global variable that in the sequence when go to the level selection the global variable is compare to the level selection button, if they are the same number then the level button changes to 1 (to unlock the level)

    So things are kind of working, you kill enemy w/ n. 2 on the level, go to level selection and the level 2 button is unlocked and you can play that new level, but on level 3 you kill enemy w/ n. 3 and then again unlock level 3 but all the previous levels (2) will be locked back because the instance variable Locked was reset back to 0.....

    I cannot make these sprites global because they are repeated many times and must have different variable numbers

    Hope I made myself understandable. How can I keep the "locked" instance variable saved? Whats the most practical way?

    I have tried PERSIST but messes up a lot of stuff... sometimes sprites are destroyed...

    the buttom for the level selection is the same sprite as the enemy... when is lock it is black and white, when unlocked it is colored (changes animation)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Assuming levels are only ever unlocked in order and you can't skip them you can use logic with one global variable which is set to highest level unlocked then when you enter the layout it unlocks all objects that instance variable value is less or equal to GV (assuming you set these up in the editor already). This way you are not changing instance variables but just comparing.

  • lionz wow man, you nailed it.

    THANK YOU

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)