Is there a way to reset static variables?

Discussion and feedback on Construct 2

Post » Tue Jul 05, 2016 4:07 am

How do we reset static variables to their default (initial) value?

I'm making a function that delete the savefile (since Construct doesn't provide an easy way to do so, which would be very useful btw ;) ).

My "deleteSavefile" function does the following:
  • Clear local storage
  • Reset global variables to default
  • Reset persistent objects
  • Send the player to the title screen

What I can't figure out how to do is to reset the static variables to their initial values. Right now, after calling this function, the player is sent to the title screen, but when clicking "New Game", it's not really a new game, because all static variables kept their values.

You folks have any tips for me? Thanks :)
B
19
S
5
Posts: 80
Reputation: 1,383

Post » Tue Jul 12, 2016 8:54 am

I'll guess you'll have to go the manual way. Set their initial value using a function and call that function whenever it's needed. Like when you are resetting the save.
B
135
S
33
G
17
Posts: 1,557
Reputation: 20,717

Post » Sat Jul 16, 2016 5:53 pm

Ah, really? That's annoying :S
B
19
S
5
Posts: 80
Reputation: 1,383


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 6 guests