is the gd file itself a class?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bgegg
#script.gd
    extends KinematicBody2D
    func printing():
    	print("hoge");

i can use above code as class.
i can access to above code like this with new.

var soruce = load("script.gd");
var instance = soruce.new();

is this class .gd file itself?

if i am wrong,do i have to do below?please your advice.

#script.gd
class printingClass:
    extends KinematicBody2D
    func printing():
    	print("hoge");
:bust_in_silhouette: Reply From: Zylann

.gd files behave like classes when you load them, yes. Thats why you can do things like this:

const MyClass = preload("my_class.gd")

var _instance = MyClass.new()

thanks for comment .i understood about that.

bgegg | 2022-04-04 22:38