Asset - Scripts GML-Classes - An extension script for GML providing OOP features.


GML-Classes is a script which adds some OOP functionality that allows you to define classes, their constructor and destructor, and call parent methods in overridden methods.
To start using it, just add this script to your project.
Highly recommended to check out the documentation.


When writing code, you may need to implement more complex structures, as well as their interaction.
If you are familiar with OOP, you might want to use classes because they are well suited for this task.

But in GML, there is no concept of classes by default.
To fix that, a special script called GML-Classes was created.
It is based on structs, but makes them more class-like in use.

Thanks to GML-Classes you can define and use classes like this:

GML-Classes provides the following features:
  1. Constructor
    The constructor initializes the object (class instance) at the time of its creation.
    Here you can initialize data, reserve memory, resources, assign links, etc.

  2. Destructor
    The destructor is executed when the object is destroyed.
    Thanks to it, you can deinitialize the object as you need.
    For example, break links, free memory, resources, etc.

  3. Calling parent method
    The ability to call the parent methods allows you to get rid of duplication of the parent code in the overridden methods, which reduces the amount of code and, as a result, makes the code more maintainable and easier to read.

A couple of important notes:
  • Class names must have a special prefix c_ or cX, where X is any upper character.
    Thank to it, GMLC finds your classes.

  • register_as_super( <parent_class> );
    Unfortunately, this line is necessary to make GMLC know about an inheritance.
    In other way, when you will try call parent's method using super(...), it will not work.
Last edited:


rIKmAN, Thanks! I fixed it.

Has anyone already tried to work with this `extension`?
I would like to know if there are any problems with GMCS.


Just discovered GMCS doesn't work when exporting HTML5. The reason is that script_get_name returns undefined and because of this the required structures are not initializing. I have no idea how to fix it.
GMS2 Manual page did not help me.
Does anyone have any ideas?


I've added a special keyword "singleton".
It means that only one instance of this class can exist.
Instances of classes marked as singleton will be created when your game starts.
class cSingleton define {
    function _constructor() {
        show_debug_message("cSingleton constructor");
    function do_something() {
        show_debug_message("cSingleton do_something");
You can access to this instance like this:

GML-Classes v1.0.3 is available on GameMaker Marketplace.