You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: engine/docs/src/guides/application_lifecycle.txt
+8-16Lines changed: 8 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -13,8 +13,7 @@ The application then enters the update loop where the application will spend a m
13
13
14
14
At some point the applications lifecycle will come to an end. Before the application quits the engine steps out of the update loop and enters a finalization stage. It prepares all loaded game objects for deletion. All object components’ +link:/ref/go#final[final()]+ functions are called, which allows for custom cleanup. Then the objects are deleted and the main collection is unloaded.
@@ -59,22 +58,19 @@ function on_message(self, message_id, message, sender)
59
58
end
60
59
----
61
60
62
-
The update loop
63
-
---------------
61
+
== The update loop
64
62
65
63
The update loop runs through a long sequence once every frame. The update sequence in the diagram below are divided into logical sequence blocks for clarity. "Dispatch messages" is also broken out separately for the same reason:
Input is is read from available devices, mapped against link:/doc/input[input bindings] and then dispatched. Any game object that has acquired input focus gets input sent to all its component +on_input()+ functions. A game object with a script component and a GUI component with a GUI script will get input to both components’ +on_input()+ functions--given that they are defined and that they have acquired input focus.
73
70
74
71
Any game object that has acquired input focus and that contain collection proxy components dispatches input further to components in the proxy collection belonging to game objects that has acquired input focus. This process continues recursively down enabled collection proxies within enabled collection proxies.
75
72
76
-
Update
77
-
------
73
+
=== Update
78
74
79
75
Each game object component in the main collection is traversed. If any of these component has a script +update(),+ then it will be called. If the component is a collection proxy, each component in the proxy collection is recursively updated with all the steps in the "update" sequence in the diagram above.
80
76
@@ -89,29 +85,25 @@ Child transforms are then done, applying any game object movement, rotation and
89
85
90
86
In the next step all posted messages are dispatched. Since any receiver component’s +on_message()+ code can post additional messages the message dispatcher will continue to dispatch posted messaged until the message queue is empty. There is, however, a limit to how many runs through the message queue the message dispatcher performs. See link:/doc/message_passing[Message passing] and the section "Advanced topics" for details.
91
87
92
-
Render update
93
-
-------------
88
+
=== Render update
94
89
95
90
The render update block dispatches messages to the @render socket (camera component "set_view_projection" messages, "set_clear_color" messages etc). The render script +update()+ is then called.
96
91
97
-
Post update
98
-
-----------
92
+
=== Post update
99
93
100
94
After the updates, a post update sequence is run. It unloads from memory collection proxies that are marked for unloading (this happens during the "dispatch messages" sequence). Any game object that is marked for deletion will call all of its components’ +final()+ functions called—if there are any. The code in +final()+ functions often posts new messages to the queue so a "dispatch messages" pass is run afterwards.
101
95
102
96
Any factory components that has been told to spawn a game object will do that next. Finally, game objects that are marked for deletion are actually deleted.
103
97
104
98
The last steps in the update loop involves dispatching @system messages ("exit", "reboot" messages, toggling the profiler, starting and stopping video capture etc). Then graphics is rendered. During the graphics rendering, video capture is done, as is any rendering of the visual profiler (see the link:/doc/scripting[Scripting documentation].)
105
99
106
-
Frame rate and collection time step
107
-
-----------------------------------
100
+
=== Frame rate and collection time step
108
101
109
102
The number of frame updates per seconds (which equals the number of update-loop runs per second) can be set in the project settings, or programmatically by sending an "set_update_frequency" message to the +@system+ socket. In addition, it is possible to set the _time step_ for collection proxies individually by sending a "set_time_step" message to the proxy. Changing a collection's time step does not affect the frame rate. It has an effect on the physics update time step as well as the "dt" variable passed to +update().+ Also note that altering the time step does not alter the number of times +update()+ will be called each frame--it is always exactly once.
110
103
111
104
(See link:/doc/collection_proxies[Collection proxies] and link:ref/collection_proxy#set_time_step[set_time_step] for details)
112
105
113
-
Finalization
114
-
------------
106
+
== Finalization
115
107
116
108
At the point when the application exits, it finishes the last update loop sequence, which will unload any collection proxies: finalizing and deleting all game objects in the proxy collection.
Copy file name to clipboardExpand all lines: engine/docs/src/guides/gui.txt
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,6 @@ A graphical user interface in Defold is a game object component that you build a
13
13
[NOTE]
14
14
====
15
15
The rendering behavior can be changed in the render script but it is usually desirable to have it that way since the user interface is a separate visual "layer" on top of the game view and you usually want HUD items and menus on certain spots on screen.
16
-
17
16
====
18
17
19
18
Because the GUI is not part of the collection’s coordinate system but is rendered independently of the game view it is not placed in a particular location in the collection editor and it has no visual representation in the collection editor. However, the GUI component have to reside in a game object that has a location in the collection. Changing that location has no effect on the GUI.
@@ -101,6 +100,7 @@ In this example the orange box node "box2" is part of layer "front" which is dra
101
100
Both "box1" and "box3" are set to layer "back". The drawing order within a layer is determined by the node’s index, it’s place in the node list. "box1" comes before "box3" and is thus drawn first, behind "box3".
102
101
103
102
=== Batch rendering
103
+
104
104
In order to render your gui as efficiently as possible, there are steps that you can take that will permit the engine to organise drawing of your gui nodes in batches, reducing the overall number of drawcalls that the engine must create. If groups of nodes meet the following conditions, then they may be handled within a single batch:
105
105
106
106
. If they are all box nodes, they use the same texture.
@@ -221,7 +221,7 @@ Text nodes behave in exactly the same way. The adjust mode applies to the invisi
221
221
222
222
Anchors control the behavior of a node’s position when the window is resized. New nodes are created _non anchored_ meaning that they are positioned relative to the center of the screen.
223
223
224
-
==== Node repositioning without anchors
224
+
=== Node repositioning without anchors
225
225
226
226
The default behavior of a created node is the following
227
227
@@ -236,7 +236,7 @@ Similarly, if the window is shrunk and gets relatively narrower, the added heigh
By setting the Xanchor and/or the Yanchor properties you can lock the position of nodes relative to the edges of the window.
242
242
@@ -249,7 +249,7 @@ In practice this means that if you set the Xanchor property to "Right" and the Y
249
249
250
250
image::images/gui/gui_anchor_topright.png["Anchor top right", align="center"]
251
251
252
-
==== Pivot
252
+
=== Pivot
253
253
254
254
Each node has a position, scale and rotation inside the GUI coordinate system. A node is placed on that position so that its pivot is at the set coordinate and any rotation is done around that same pivot.
0 commit comments