From my C# background, where I very often used extension methods to enrich existing classes, I wonder, if something like this is possible in GML too.
I know that I can just write a normal function, that does the job, but I am looking for a more fancy solution to this.
What I want to do:
I want to inject a method into the scribble object.
draw is nice and good for 99,99% of my usecases, however, sometimes I do not want the text to be rendered to screen directly, I want it on a surface.
Something as simple as that (using Canvas library from @sweet hound )
canvas.Start();
scrib.draw(x,y);
canvas.Finish();
just redirect the draw to a surface, nothing SciFi here.
But I don't want a function, I want to be able to invoke
scrib.drawToCanvas(canvas,x,y);
So, basically, I want to enhance the scribble object with a new method, drawToCanvas and it shall do the job.
Can this be done? create a new static method in another class?