mirror of
https://github.com/godotengine/godot.git
synced 2025-02-16 07:40:36 +00:00
hoho
parent
6376e9f763
commit
801b68f07e
@ -151,11 +151,11 @@ Objects can have a set of signals defined (similar to Delegates in other languag
|
||||
```c++
|
||||
obj->connect(<signal>,target_instance,target_method)
|
||||
//for example
|
||||
obj->connect("enter_scene",this,"_node_entered_scene")
|
||||
obj->connect("enter_tree",this,"_node_entered_tree")
|
||||
|
||||
```
|
||||
|
||||
The method "_node_entered_scene" must be registered to the class using ObjectTypeDB::register_method (explained before).
|
||||
The method "_node_entered_tree" must be registered to the class using ObjectTypeDB::register_method (explained before).
|
||||
|
||||
Addign signals to a class is done in _bind_method, using the ADD_SIGNAL macro, example:
|
||||
|
||||
|
@ -497,7 +497,7 @@ func _myfunc():
|
||||
```
|
||||
### Built-In engine callbacks
|
||||
|
||||
However, as a single exception, most engine built-in callbacks (not the signals!, just overridable functions like _notification, _process, _init, _input, _ready, _draw, _enter_scene, etc) happen in all levels of inheritance. Calling super on those is not needed.
|
||||
However, as a single exception, most engine built-in callbacks (not the signals!, just overridable functions like _notification, _process, _init, _input, _ready, _draw, _enter_tree, etc) happen in all levels of inheritance. Calling super on those is not needed.
|
||||
|
||||
## Static Functions
|
||||
|
||||
|
@ -46,7 +46,7 @@ While other viewports can be created in the scene (for split-screen effects and
|
||||
### Scene Tree
|
||||
|
||||
When a node is connected, directly or indirectly, to the root viewport, it becomes part of the _Scene Tree_.
|
||||
This means that, as explained in previous tutorials, will get the _enter_scene() and _ready() callbacks (as well as _exit_scene()).
|
||||
This means that, as explained in previous tutorials, will get the _enter_tree() and _ready() callbacks (as well as _exit_tree()).
|
||||
|
||||
<p align="center"><img src="images/activescene.png"></p>
|
||||
|
||||
@ -62,9 +62,9 @@ Most node operations in Godot, such as drawing 2D, processing or getting notific
|
||||
|
||||
1. A scene is loaded from disk or created by scripting.
|
||||
2. The root node of that scene (only one root, remember?) is added as either a child of the “root” Viewport (from SceneTree), or to any child or grand-child of it.
|
||||
3. Every node of the newly added scene, will receive the “enter_scene” notification ( _enter_scene() callback in GDScript) in top-to-bottom order.
|
||||
3. Every node of the newly added scene, will receive the “enter_tree” notification ( _enter_tree() callback in GDScript) in top-to-bottom order.
|
||||
4. An extra notification, “ready” ( _ready() callback in GDScript) is provided for convenience, when a node and all it’s children are inside the active scene.
|
||||
5. When a scene (or part of it) is removed, they receive the “exit scene” notification ( _exit_scene() callback in GDScript) in bottom-to-top order
|
||||
5. When a scene (or part of it) is removed, they receive the “exit scene” notification ( _exit_tree() callback in GDScript) in bottom-to-top order
|
||||
|
||||
|
||||
|
||||
|
@ -98,14 +98,14 @@ As mentioned before, it's better to use these functions. Nodes provide many usef
|
||||
|
||||
```python
|
||||
|
||||
func _enter_scene():
|
||||
pass # When the node enters the active scene, this function is called. Children nodes have not entered the active scene yet. In general, it's better to use _ready() for most cases.
|
||||
func _enter_tree():
|
||||
pass # When the node enters the _Scene Tree_, it become acive and this function is called. Children nodes have not entered the active scene yet. In general, it's better to use _ready() for most cases.
|
||||
|
||||
func _ready():
|
||||
pass # This function is called after _enter_scene, but it ensures that all children nodes have also entered the active scene, and they are all functional.
|
||||
pass # This function is called after _enter_tree, but it ensures that all children nodes have also entered the _Scene Tree_, and became active.
|
||||
|
||||
func _exit_scene():
|
||||
pass # When the node exists the active scene, this function is called. Children nodes have all exited the active scene at this point.
|
||||
func _exit_tree():
|
||||
pass # When the node exists the _Scene Tree_, this function is called. Children nodes have all exited the _Scene Tree_ at this point and all became inactive.
|
||||
|
||||
func _process(delta):
|
||||
pass # When set_process() is enabled, this is called every frame
|
||||
|
Loading…
Reference in New Issue
Block a user