[ANSWERED] What does "<Class>.super.new(self, {})" do?
Posted: Fri Nov 04, 2022 4:03 pm
Hey,
I'm new(ish) to LOVE, I have a bit of background knowedge of object-oriented programming but usually with "higher-level" engines that do a lot of the heavy lifting when it comes to creating/storing/manipulating objects.
I'm currently working on a project in LOVE using rxi's Classic library and I've got the basics of it down, I can create new objects, give properties to those objects, create methods for those objects etc. but I'm a bit stuck with what exactly <Class>.super.new(self, {}) is and what it does.
I know it is something to do with setting (or... getting?) the "super" ("parent class") of an object but I don't understand what the first and second arguments represent or why it is necessary to insert this particular piece of code when creating a new class; for example I had a piece of code that wasn't working until I inserted <Class>.super.new(self, {}) and then it worked no problem, but I don't understand what actually happened and why.
If anyone could explain this to me I'd be really grateful, I've had a quick search of the LOVE forums, Stack Overflow etc. but there's nothing that answered my question in a way I could understand and I'm now more confused than I initially was lol.
Thanks!
I'm new(ish) to LOVE, I have a bit of background knowedge of object-oriented programming but usually with "higher-level" engines that do a lot of the heavy lifting when it comes to creating/storing/manipulating objects.
I'm currently working on a project in LOVE using rxi's Classic library and I've got the basics of it down, I can create new objects, give properties to those objects, create methods for those objects etc. but I'm a bit stuck with what exactly <Class>.super.new(self, {}) is and what it does.
I know it is something to do with setting (or... getting?) the "super" ("parent class") of an object but I don't understand what the first and second arguments represent or why it is necessary to insert this particular piece of code when creating a new class; for example I had a piece of code that wasn't working until I inserted <Class>.super.new(self, {}) and then it worked no problem, but I don't understand what actually happened and why.
If anyone could explain this to me I'd be really grateful, I've had a quick search of the LOVE forums, Stack Overflow etc. but there's nothing that answered my question in a way I could understand and I'm now more confused than I initially was lol.
Thanks!