11clock
Member
For those who haven't used object-oriented programming languages, a scope defines the accessibility of a variable or method (scripts replace methods in GMS).
Private: Only available in the object that defines the variable or method.
Protected: Only available in the object that defines the variable or method, and its children as well.
Public: Available to any object that has a reference to the object that defines the variable or method. For example: player.HP
Global: Available to any object, not really anchored to the object that defines it.
One of my biggest problems with GMS is that variables can only either be global or public, and scripts can only be global. You can make notes for the variables to help organize them better (although more scopes would be way better), but the killer here is that scripts are global only. This results in very unorganized code that is spread out. If I want a Dog object to Bark(), I have to make the method available to all objects. The only way to really combat this is to organize scripts into folders.
The closest you could get to defining a script to a specific object in GMS is a user event. But you only have so many of these, they cannot be renamed to more sensible names, and they cannot take in arguments.
So I would really like it if GMS2 allows us to have more scopes for variables and, more importantly, scripts. It is absolutely crucial for organizing code in long-term projects, especially object-oriented code.
So will GMS2 have more scoping options for variables and scripts?
Private: Only available in the object that defines the variable or method.
Protected: Only available in the object that defines the variable or method, and its children as well.
Public: Available to any object that has a reference to the object that defines the variable or method. For example: player.HP
Global: Available to any object, not really anchored to the object that defines it.
One of my biggest problems with GMS is that variables can only either be global or public, and scripts can only be global. You can make notes for the variables to help organize them better (although more scopes would be way better), but the killer here is that scripts are global only. This results in very unorganized code that is spread out. If I want a Dog object to Bark(), I have to make the method available to all objects. The only way to really combat this is to organize scripts into folders.
The closest you could get to defining a script to a specific object in GMS is a user event. But you only have so many of these, they cannot be renamed to more sensible names, and they cannot take in arguments.
So I would really like it if GMS2 allows us to have more scopes for variables and, more importantly, scripts. It is absolutely crucial for organizing code in long-term projects, especially object-oriented code.
So will GMS2 have more scoping options for variables and scripts?