stop number of lives from resetting on new layout

0 favourites
  • 3 posts
From the Asset Store
Create your game with this complete pack of images and animations!
  • I'm sure this is straightforward but I can't find the answer on the forums and everything I have tried doesn't work....

    I have a global variable PlayerLives=3 this works fine in the first layout. As a life is lost it subtracts 1 from the global variable.

    The problem is that I have a reset global variables to default event at the start of a new layout. So when a new level of the game begins the lives go back to 3. I want the number of lives to stop resetting on start of layout. If I end level 1 with 2 lives remaining, I want to begin level 2 with 2 lives remaining.

    I think the solution has something to do with a local variable for number of lives but i'ts not working out for me.

    Can someone please point me in the right direction. Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • A. Don't reset global variables to default (use local variables for those you DO want to reset).

    B. Put PlayerLives as an instance variable in an object with a Persist Behavior.

    C. Store PlayerLives in another global data object such as an Array or Dictionary.

  • Good tips, thank you. Got it working now

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