static varibles on objects

Discussion and feedback on Construct 2

Post » Fri Jun 05, 2015 7:45 pm

We need static variables for object types. Both for families and object types. Why no exist?

I am referring to static as defined by programers, not construct 2.

https://www.google.com/search?q=static+ ... 8&oe=utf-8
"A static variable is one that's associated with a class, not objects of that class..."

In other words, if you set an objects static variable it will be reflected across all instances of that object.
Last edited by ruskul on Fri Jun 05, 2015 8:52 pm, edited 1 time in total.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Post » Fri Jun 05, 2015 8:03 pm

Pretty sure instances variables are static (since they are not resetted every tick).

Maybe you want the opposite?
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Fri Jun 05, 2015 8:06 pm

Could always set the val to 0 at the bottom of the sheet or event.
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Fri Jun 05, 2015 9:03 pm

@Tokinsom @Aphrodite - Thanks for the reply. I didn't think to mention I was referring to static variables as is defined by programing. I forgot that construct 2 has "static" variables. A bad name to use when the programing world already uses "static" to define a variable that is attached to the object rather than the instance of that object. Basically, if you change a static variable on an object, regardless from which instance you accessed it, it reflects across all instances of that object. Its kind of like a global variable but for only the instances from the object that has it.

I updated the OP to reflect this.

If you had a mob of enemies that react as one, you could have a static variable "IsAlert". If the player overlapped a trigger object, you could set IsAlert to true on one instance of the enemy object type. At this point all of those enemies would have "IsAlert" as true. It is much better than using a global variable to do the same thing.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 11 guests