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: docs/en/manuals/camera.md
+31-4Lines changed: 31 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,6 +48,13 @@ Orthographic Projection
48
48
Orthographic Zoom
49
49
: (**Orthographic camera only**) - The zoom used for the orthographic projection (> 1 = zoom in, < 1 = zoom out).
50
50
51
+
Orthographic Mode
52
+
: (**Orthographic camera only**) - Controls how the orthographic camera determines zoom relative to the window size and your design resolution (the values in `game.project` → `display.width/height`).
53
+
-`Fixed` (uses constant zoom): Uses the current `Orthographic Zoom` value as-is.
54
+
-`Auto Fit` (contain): Automatically adjusts zoom so the full design area fits inside the window. May show extra content on sides or top/bottom.
55
+
-`Auto Cover` (cover): Automatically adjusts zoom so the design area covers the entire window. May crop on sides or top/bottom.
56
+
Available only when `Orthographic Projection` is enabled.
57
+
51
58
52
59
## Using the camera
53
60
@@ -83,9 +90,11 @@ The scripting `camera` module has multiple functions that can be used to manipul
83
90
camera.get_aspect_ratio(camera) -- get aspect ratio
84
91
camera.get_far_z(camera) -- get far z
85
92
camera.get_fov(camera) -- get field of view
93
+
camera.get_orthographic_mode(camera) -- get orthographic mode (one of camera.ORTHO_MODE_*)
86
94
camera.set_aspect_ratio(camera, ratio) -- set aspect ratio
87
95
camera.set_far_z(camera, far_z) -- set far z
88
96
camera.set_near_z(camera, near_z) -- set near z
97
+
camera.set_orthographic_mode(camera, camera.ORTHO_MODE_AUTO_FIT) -- set orthographic mode
89
98
...Andsoforth
90
99
```
91
100
@@ -125,7 +134,7 @@ The view matrix provided by the camera defines the position and orientation of t
125
134
126
135
### Render script
127
136
128
-
Starting with Defold 1.9.6, when using the default render script Defold will automatically set the last enabled camera that should be used for rendering. Before this change, a script somewhere in the project needed to explicitly send the `use_camera_projection` message to the renderer to notify it that the view and projection from camera components should be used. This is no longer necessary, but it is still possible to do so for backwards compatibility purposes.
137
+
When using the default render script Defold will automatically set the last enabled camera that should be used for rendering. Before this change, a script somewhere in the project needed to explicitly send the `use_camera_projection` message to the renderer to notify it that the view and projection from camera components should be used. This is no longer necessary, but it is still possible to do so for backwards compatibility purposes.
129
138
130
139
Alternatively, you can set a specific camera that should be used for rendering in a render script. This could be useful in cases where you need to control more specifically which camera should be used for rendering, for example in a multiplayer game.
131
140
@@ -163,6 +172,22 @@ You can zoom in and out when using an orthographic camera by changing the *Ortho
163
172
go.set("#camera", "orthographic_zoom", 2)
164
173
```
165
174
175
+
When using an orthographic camera you can also switch how zoom is determined using the `Orthographic Mode` setting or via script:
176
+
177
+
```lua
178
+
-- get current mode (one of camera.ORTHO_MODE_FIXED, _AUTO_FIT, _AUTO_COVER)
179
+
localmode=camera.get_orthographic_mode("#camera")
180
+
181
+
-- switch to auto-fit (contain) to always keep the full design area visible
The concept behind adaptive zoom is to adjust the camera zoom value when the resolution of the display change from the initial resolution set in *game.project*.
@@ -202,6 +227,8 @@ end
202
227
203
228
A complete example of adaptive zoom can be seen in [this sample project](https://github.com/defold/sample-adaptive-zoom).
204
229
230
+
Note: With an orthographic camera you can now achieve contain/cover behavior without custom code by setting `Orthographic Mode` to `Auto Fit` (contain) or `Auto Cover` (cover). In these modes the effective zoom is computed automatically based on window size and your design resolution.
231
+
205
232
206
233
### Following a game object
207
234
@@ -264,13 +291,13 @@ A camera has a number of different properties that can be manipulated using `go.
264
291
: The orthographic camera zoom (`number`).
265
292
266
293
`aspect_ratio`
267
-
: Added in Defold 1.4.8. The ratio between the frustum width and height. Used when calculating the projection of a perspective camera. (`number`).
294
+
: The ratio between the frustum width and height. Used when calculating the projection of a perspective camera. (`number`).
268
295
269
296
`view`
270
-
: Added in Defold 1.4.8. The calculated view matrix of the camera. READ ONLY. (`matrix4`).
297
+
: The calculated view matrix of the camera. READ ONLY. (`matrix4`).
271
298
272
299
`projection`
273
-
: Added in Defold 1.4.8. The calculated projection matrix of the camera. READ ONLY. (`matrix4`).
300
+
: The calculated projection matrix of the camera. READ ONLY. (`matrix4`).
Copy file name to clipboardExpand all lines: docs/en/manuals/debugging-game-and-system-logs.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ The game log shows all of the output from the engine, native extensions and your
10
10
System logs are generated by the operating system and it can provide additional information that can help you pinpoint a problem. The system logs can contain stack traces for crashes and low memory warnings.
11
11
12
12
::: important
13
-
The game log will only show information in debug builds. The log will be completely emptyin release builds.
13
+
Console/on-screen logging only shows information in Debug builds. In Release builds the console log is empty, but you can enable file logging in Release by setting the project setting "Write Log File" to "Always". See details below.
14
14
:::
15
15
16
16
## Reading the game log from the editor
@@ -87,7 +87,13 @@ This will install the app on your device, start it and automatically attach a LL
87
87
88
88
## Reading the game log from the log file
89
89
90
-
If you enable the *Write Log* setting in *game.project*, any game output will be written to disk, to a file called "`log.txt`". Here is how you extract the file if you run the game on device:
90
+
Use the project setting "Write Log File" in *game.project* to control file logging:
91
+
92
+
- "Never": Do not write a log file.
93
+
- "Debug": Write a log file only for Debug builds.
94
+
- "Always": Write a log file for both Debug and Release builds.
95
+
96
+
When enabled, any game output will be written to disk to a file named "`log.txt`". Here is how you extract the file if you run the game on device:
91
97
92
98
iOS
93
99
: Connect your device to a computer with macOS and Xcode installed.
Copy file name to clipboardExpand all lines: docs/en/manuals/project-settings.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,8 +66,14 @@ Publisher name.
66
66
#### Developer
67
67
Developer name.
68
68
69
-
#### Write Log
70
-
When checked, the engine will write a log file. If running more than one instance from the editor the file will be named *instance_2_log.txt* with `2` being the instance index. If running a single instance or from a bundle the file will be named *log.txt* The location of the log file will be one of the following paths (tried in order):
69
+
#### Write Log File
70
+
Controls when the engine writes a log file. Options:
71
+
72
+
- "Never": Do not write a log file.
73
+
- "Debug": Write a log file only for Debug builds.
74
+
- "Always": Write a log file for both Debug and Release builds.
75
+
76
+
If running more than one instance from the editor the file will be named *instance_2_log.txt* with `2` being the instance index. If running a single instance or from a bundle the file will be named *log.txt*. The location of the log file will be one of the following paths (tried in order):
71
77
72
78
1. The path specified in *project.log_dir* (hidden setting)
Copy file name to clipboardExpand all lines: docs/en/manuals/render.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -137,6 +137,20 @@ msg.post("@render:", "use_fixed_projection", { near = -1, far = 1, zoom = 2 })
137
137
138
138
When using the default render script and there are enabled [Camera components](/manuals/camera) available in the project, they will take precedence over any other view / projections set in the render script. To read more about how to work with camera components in render scripts, please consult the [Camera documentation](/manuals/camera).
139
139
140
+
Orthographic cameras support an `Orthographic Mode` that controls how the camera adapts to the window:
141
+
-`Fixed` uses the camera’s `Orthographic Zoom` value.
142
+
-`Auto Fit` (contain) keeps the full design area visible.
143
+
-`Auto Cover` (cover) fills the window and may crop.
144
+
145
+
You can switch modes in the Editor or at runtime via the Camera API:
146
+
147
+
```lua
148
+
-- Use auto-fit behavior with an orthographic camera
The render API in Defold lets developers perform something called frustum culling. When frustum culling is enabled any graphics that lies outside of a defined bounding box or frustum will be ignored. In a large game world where only a portion is visible at a time, frustum culling can dramatically reduce the amount of data that needs to be sent to the GPU for rendering, thus increasing performance and saving battery (on mobile devices). It is common to use the view and projection of the camera to create the bounding box. The default render script uses the view and projection (from the camera) to calculate a frustum.
Copy file name to clipboardExpand all lines: docs/pl/manuals/project-settings.md
+19-6Lines changed: 19 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,12 +21,25 @@ Tytuł aplikacji
21
21
#### Version
22
22
Wersja aplikacji
23
23
24
-
#### Write Log
25
-
Kiedy opcja zapisu logów jest zaznaczona, silnik zapisze wszystkie logi do pliku *log.txt* w głównej lokalizacji Twojego projektu. Gdy uruchomisz grę na systemie iOS, plik można będzie otworzyć przez iTunes w zakładce *Apps* w sekcji *File Sharing*. W systemie Android natomiast, plik jest przechowywany w zewnętrznej lokalizacji aplikacji (ang. app's external storage). Podczas uruchamiania aplikacji deweloperskiej *dmengine*, możesz podejrzeć logi używając komendy:
Określa, kiedy silnik zapisuje log do pliku. Opcje:
26
+
27
+
- "Never": nie zapisuj pliku logu.
28
+
- "Debug": zapisuj plik logu tylko dla buildów Debug.
29
+
- "Always": zapisuj plik logu zarówno dla buildów Debug, jak i Release.
30
+
31
+
Jeśli uruchamiasz więcej niż jedną instancję z edytora, plik będzie nazwany *instance_2_log.txt*, gdzie `2` to indeks instancji. Jeśli uruchamiasz pojedynczą instancję lub paczkę, plik będzie nazwany *log.txt*. Lokalizacja pliku logu będzie jedną z poniższych (sprawdzane w tej kolejności):
32
+
33
+
1. Ścieżka określona w *project.log_dir* (ukryte ustawienie)
34
+
2. Systemowa ścieżka logów:
35
+
* macOS/iOS: `NSDocumentDirectory`
36
+
* Android: `Context.getExternalFilesDir()`
37
+
* Inne: katalog aplikacji
38
+
3. Ścieżka wsparcia aplikacji:
39
+
* macOS/iOS: `NSApplicationSupportDirectory`
40
+
* Windows: `CSIDL_APPDATA` (np. `C:\Users\<username>\AppData\Roaming`)
41
+
* Android: `Context.getFilesDir()`
42
+
* Linux: zmienna środowiskowa `HOME`
30
43
31
44
#### Compress Archive
32
45
Umożliwia kompresowanie archiwów podczas budowania paczki. Zauważ, że dotyczy to wszystkich platform oprócz systemu Android, gdzie plik apk zawiera od razy skompresowane dane.
: (**Только для ортографической камеры**) — управляет тем, как ортографическая камера определяет зум относительно размера окна и ваших значений дизайна (`game.project` → `display.width/height`).
53
+
-`Fixed` (постоянный зум): используется текущее значение `Orthographic Zoom`.
54
+
-`Auto Fit` (вписать): автоматически подбирает зум так, чтобы вся дизайн-область помещалась в окно. Возможен дополнительный контент по бокам/сверху/снизу.
55
+
-`Auto Cover` (заполнить): автоматически подбирает зум так, чтобы дизайн-область заполняла окно целиком. Возможна обрезка по бокам/сверху/снизу.
56
+
Доступно только при включённой `Orthographic Projection`.
57
+
51
58
52
59
## Использование камеры
53
60
@@ -83,9 +90,11 @@ render.set_camera()
83
90
camera.get_aspect_ratio(camera) -- получить соотношение сторон
84
91
camera.get_far_z(camera) -- получить дальнюю плоскость отсечения
85
92
camera.get_fov(camera) -- получить угол обзора
93
+
camera.get_orthographic_mode(camera) -- получить ортографический режим (одно из camera.ORTHO_MODE_*)
86
94
camera.set_aspect_ratio(camera, ratio) -- установить соотношение сторон
87
95
camera.set_far_z(camera, far_z) -- установить дальнюю плоскость отсечения
88
96
camera.set_near_z(camera, near_z) -- установить ближнюю плоскость отсечения
97
+
camera.set_orthographic_mode(camera, camera.ORTHO_MODE_AUTO_FIT) -- установить ортографический режим
89
98
... и другие
90
99
```
91
100
@@ -163,6 +172,22 @@ end
163
172
go.set("#camera", "orthographic_zoom", 2)
164
173
```
165
174
175
+
Также для ортографической камеры можно выбрать способ определения зума с помощью параметра `Orthographic Mode` или из кода:
176
+
177
+
```lua
178
+
-- текущий режим (одно из: camera.ORTHO_MODE_FIXED, _AUTO_FIT, _AUTO_COVER)
179
+
localmode=camera.get_orthographic_mode("#camera")
180
+
181
+
-- включить режим "вписать" (contain), чтобы дизайн-область всегда полностью помещалась в окно
Адаптивный зум — это изменение значения зума камеры при изменении разрешения экрана относительно первоначального разрешения, заданного в *game.project*.
@@ -202,6 +227,8 @@ end
202
227
203
228
Полный пример адаптивного зума доступен в [этом примерном проекте](https://github.com/defold/sample-adaptive-zoom).
204
229
230
+
Примечание: Для ортографической камеры типичное поведение «вписать/заполнить» можно получить без пользовательского кода, установив `Orthographic Mode` в `Auto Fit` (вписать) или `Auto Cover` (заполнить). В этих режимах эффективный зум рассчитывается автоматически на основе размера окна и заданного разрешения дизайна.
231
+
205
232
206
233
### Следование за игровым объектом
207
234
@@ -264,13 +291,13 @@ end
264
291
: Масштаб ортографической камеры (`number`).
265
292
266
293
`aspect_ratio`
267
-
: Добавлено в Defold 1.4.8. Соотношение ширины и высоты усечённой пирамиды. Используется при вычислении проекции перспективной камеры. (`number`).
294
+
: Соотношение ширины и высоты усечённой пирамиды. Используется при вычислении проекции перспективной камеры. (`number`).
268
295
269
296
`view`
270
-
: Добавлено в Defold 1.4.8. Вычисленная матрица вида камеры. ТОЛЬКО ДЛЯ ЧТЕНИЯ. (`matrix4`).
297
+
: Вычисленная матрица вида камеры. ТОЛЬКО ДЛЯ ЧТЕНИЯ. (`matrix4`).
271
298
272
299
`projection`
273
-
: Добавлено в Defold 1.4.8. Вычисленная матрица проекции камеры. ТОЛЬКО ДЛЯ ЧТЕНИЯ. (`matrix4`).
300
+
: Вычисленная матрица проекции камеры. ТОЛЬКО ДЛЯ ЧТЕНИЯ. (`matrix4`).
Copy file name to clipboardExpand all lines: docs/ru/manuals/debugging-game-and-system-logs.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ brief: В этом руководстве объясняется, как чит
10
10
Системные логи создаются операционной системой и могут содержать дополнительную информацию, которая может помочь вам выявить проблему. Системные логи могут содержать трассировки стека для сбоев и предупреждений о нехватке памяти.
11
11
12
12
::: important
13
-
В логе игры будет отображаться информация только в отладочных сборках. В сборках релизов лог будет полностью пустым.
13
+
Вывод в консоль/на экран показывается только в Debug-сборках. В Release-сборках консольный лог пуст, но вы можете включить запись лога в файл для Release, установив в настройках проекта параметр "Write Log File" в значение "Always". Подробнее см. ниже.
Если вы включите параметр *Write Log* в *game.project*, любой вывод игры будет записываться на диск в файл с именем "log.txt". Вот как можно извлечь файл, если вы запускаете игру на устройстве:
90
+
Используйте параметр проекта "Write Log File" в *game.project*, чтобы управлять записью лога в файл:
91
+
92
+
- "Never": не записывать лог в файл.
93
+
- "Debug": записывать файл лога только для Debug-сборок.
94
+
- "Always": записывать файл лога как для Debug, так и для Release-сборок.
95
+
96
+
Если запись включена, весь вывод игры будет записываться на диск в файл "`log.txt`". Вот как можно извлечь файл, если вы запускаете игру на устройстве:
91
97
92
98
iOS
93
99
: Подключите ваше устройство к компьютеру с установленными macOS и Xcode.
0 commit comments