静态函数
静态函数是类的成员函数,即使对象尚未初始化也可以调用。
静态类不能访问其类的任何变量,除了静态变量。
Godot GDSCript 没有静态变量。
您无需创建类实例即可使用静态函数。
当您不依赖任何类成员(变量)时,最好使用静态函数。
# Animal Classextends Node2Dclass_name Animalstatic func printHi() -> void:print("Hello!")
# Another Classextends Node2D# Inside of some function_ready():# You do not need to instantiate the animal class in order to use printHi()Animal.printHi() # prints "Hello" to console
