Consider the following example:
class State:
def begin():
do_some_basic_init()
class Running extends State:
def begin():
??? # Want to call super method
do_some_sub_state_init()
There are some code that I want to reuse from superclass within the overridden method, which is really common. I know that in python can use State.begin(self)
, but I get an error with this in GDScript, and calling State.begin()
yields a runtime error. I also didn't find any reference about this in documentation. Is it supported?
just call the function with a prepended .
for your example:
class State:
func begin():
do_some_basic_init()
class Running extends State:
func begin():
.begin()
do_some_sub_state_init()
this is also documented
Oops, I guess I'm not looking carefully enough. Thanks and my apologies :-)
How do you do that with a grandparent?
A
f()
B extends A
f():
.f() #calls A.f()
C extends B
f():
.f() #calls B.f(), I want A.f()
wouldn't that just be A.f()
?
Most helpful comment
just call the function with a prepended
.
for your example:
this is also documented