stop number of lives from resetting on new layout

Get help using Construct 3!

Post » Tue Oct 24, 2017 7:23 pm

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!
B
5
Posts: 18
Reputation: 261

Post » Tue Oct 24, 2017 8:13 pm

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.
Mistakes were made.
B
62
S
30
G
134
Posts: 1,976
Reputation: 75,479

Post » Tue Oct 24, 2017 9:02 pm

Good tips, thank you. Got it working now :D
B
5
Posts: 18
Reputation: 261


Return to How do I...?

Who is online

Users browsing this forum: 3mtpeak, Akash11, JPatchZ and 0 guests