BindNode
Use the BindNode property wrapper in any subclass of Node to retrieve the node from the current container that matches the name of the property.
NodeExtensions.swift:28@propertyWrapper struct BindNode<Value> where Value : Node
For example:
class MyElements: CanvasLayer {
@BindNode var GameOverLabel: Label
}
The above is equivalent to calling
getNode(path: NodeName("GameOverLabel")) as! Label
Notice that nodes wrapped with @BindNode will crash at runtime if you do not have a node in your scene that matches that name. If your are dealing with dynamic content or you are developing and things change often, you might use the alternative SceneTree
which allow you to use a nullable value, so you can test at runtime if the node exists or not.