question about extends(inheritence).Are the child class already extended?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bgegg

i have question about extends
1:Can parents not extend their children?
for example,node2d can not extend sprite class ,but CanvasItem and Node and Object can it.
Although only upper classes can be extended, node2d can already use canvasitem, node, object properties and methods. What does it mean to extend?

2:Do the node types and the extends statement have to match?
Should I write “extends Node2D” in node2d node?

3:Why can I use position2d when inheriting canvasitem? position2d is a child of canvasitem.

enter image description here

please tell me.

:bust_in_silhouette: Reply From: volzhs

1: you can consider a few words are skipped. every each gdscript file can be considered as a class.

(class ThisClass) extends Node2D

2: not necessarily exact match.

3: no. CanvasItem class does not have position property. Node2D has it. you can check this on in-editor help also.

Thank you
Are extensions used for limit function(method and propertie)?
If i extend canvasitem with a script attached to node2d node, the functionality is limited.

bgegg | 2019-05-10 12:55