I’m back with another question, this time it’s about *temp
I believe the nature of *temp is that value in “*temp a” will be cleared once we move to another files,
but why it still prints “100” just like the first time I initiated it?
I need some clarification regarding the nature of *temp, thank you.
The scope of scene A is not removed from memory when you transition to a subroutine. The subroutine scene is placed on the scene stack, then removed and the temp variables from scene A are not reset when you go back.
so on what occasion that values in *temp will be cleared?
I believe *temp will play a major role on how I code my game, so I kinda need to know how it works,
it would be disastrous when some values just disappearing on runtime because I miscalculated how *temp works.
thank you very much
Use temp variables when you want to use that variable only in the scope of that particular scene. Even if you go from scene A to B then back to A again, they wont be cleared unless you reinitialize them. But, temp variables are only referencable from the scene you create them.
TLDR: use regular variables for permanent states you want to transfer across scenes (player stats, skills, etc) and temp variables for states that dont influence states in other scenes.
This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.