How do I create local group variables once

Just started using Construct 2? Post your questions here

Post » Sun Mar 20, 2016 10:56 am

Is it possible to create local variables inside a group that won't be recreated on each tick?
By far what I see is this:
I create a local variable in a group "foo = 5",
then, in the same group "System -> on every tick", I do "foo+=5"
after that I use this variable and expect it to increase by 5 on every frame.
But all I have is 10 every time!

The solution to this is to make this variable global, but I don't want to produce global variables, actually I want to avoid it whatsoever.
Posts: 30
Reputation: 540

Post » Sun Mar 20, 2016 11:03 am

Make it static.

By default, local variables reset to their initial value whenever entering their scope (usually every tick), like local variables in programming languages. If the variable is marked static in the Event Variable dialog it will persist its value permanently, like a global variable.
Posts: 500
Reputation: 2,355

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest