I have a rather general question regarding OOP. How do constructor functions execute with multiple class extensions?
I’m making an orbital physics simulation, and every spatial body is of the class SpaceObject, which extends Sprite.
Then, I have all earth-type planets be of the class Earth, which extends SpaceObject.
There are certain parameters that I’d like to set for every single SpaceObject (like position and size) in the constructor function, and certain parameters (like density and mass) that I’d like to set in the constructor of class Earth.
But from the main timeline, when I create an instance of class Earth, I can only enter the parameters of the Earth constructor, ie
var planet1:Earth = new Earth(density, mass)
Or I can create an instance of SpaceObject:
var planet1:SpaceObject = new SpaceObject(position, size)
But then “planet1” is not of class Earth.
Is there any way to go around this or can I only call the constructor of the last, most specific, class?
I’ve looked through the help documentation for hours but found nothing. Please help