Reading tutorials for Godot I've seen both e.g.
extends StaticBody2D
class_name Foo
and
class_name Foo extends StaticBody2D
Are these equivalent? Is one preferred over the other? (And if so, why?)
Both lines are identical for newer versions of godot.
There was a time around 2019, where extends
needed to be before any class_name declaration, but they removed this.
So both examples lead to the same result: class_name
registers a new Type "Foo" in the godot editor which extends StaticBody2D.
That being said, there is an official GDScript style guide. In the chapter Code Order they suggest to put class_name
first and then in a serparate line extends
So if you want to follow the style guide, your code should look like this:
class_name Foo
extends StaticBody2D