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
If following a game object this will add a deadzone around the camera position where the camera position will not update. If the target moves to the edge of the deadzone the camera will start to follow until the target returns within the bounds of the deadzone.
211
264
212
265
**PARAMETERS**
213
-
*`camera_id` (hash|url)
266
+
*`camera_id` (hash|url|nil) nil for the first camera
214
267
*`left` (number) - Number of pixels to the left of the camera
215
268
*`top` (number) - Number of pixels above the camera
216
269
*`right` (number) - Number of pixels to the right of the camera
@@ -221,18 +274,19 @@ If following a game object this will add a deadzone around the camera position w
221
274
Limits the camera position to within the specified rectangle.
222
275
223
276
**PARAMETERS**
224
-
*`camera_id` (hash|url)
277
+
*`camera_id` (hash|url|nil) nil for the first camera
225
278
*`left` (number) - Left edge of the camera bounds
226
279
*`top` (number) - Top edge of camera bounds
227
280
*`right` (number) - Right edge of camera bounds
228
281
*`bottom` (number) - Bottom edge of camera bounds
229
282
283
+
---
230
284
231
285
### camera.screen_to_world(camera_id, screen)
232
286
Translate [screen coordinates](#screen-coordinates) to world coordinates, based on the view and projection of the camera.
233
287
234
288
**PARAMETERS**
235
-
*`camera_id` (hash|url)
289
+
*`camera_id` (hash|url|nil) nil for the first camera
236
290
*`screen` (vector3) Screen coordinates to convert
237
291
238
292
**RETURN**
@@ -243,7 +297,7 @@ Translate [screen coordinates](#screen-coordinates) to world coordinates, based
243
297
Translate [window coordinates](#window-coordinates) to world coordinates, based on the view and projection of the camera.
244
298
245
299
**PARAMETERS**
246
-
*`camera_id` (hash|url)
300
+
*`camera_id` (hash|url|nil) nil for the first camera
247
301
*`window` (vector3) Window coordinates to convert
248
302
249
303
**RETURN**
@@ -254,7 +308,7 @@ Translate [window coordinates](#window-coordinates) to world coordinates, based
254
308
Translate [screen boundaries](#screen-coordinates) (corners) to world coordinates, based on the view and projection of the camera.
255
309
256
310
**PARAMETERS**
257
-
*`camera_id` (hash|url)
311
+
*`camera_id` (hash|url|nil) nil for the first camera
258
312
259
313
**RETURN**
260
314
*`bounds` (vector4) Screen bounds (x = left, y = top, z = right, w = bottom)
@@ -264,7 +318,7 @@ Translate [screen boundaries](#screen-coordinates) (corners) to world coordinate
264
318
Translate world coordinates to [screen coordinates](#screen-coordinates), based on the view and projection of the camera, optionally taking into account an adjust mode. This is useful when manually culling game objects and you need to determine if a world coordinate will be visible or not. It can also be used to position gui nodes on top of game objects.
265
319
266
320
**PARAMETER**
267
-
*`camera_id` (hash|url)
321
+
*`camera_id` (hash|url|nil) nil for the first camera
268
322
*`world` (vector3) World coordinates to convert
269
323
*`adjust_mode` (number) One of gui.ADJUST_FIT, gui.ADJUST_ZOOM and gui.ADJUST_STRETCH, or nil to not take into account the adjust mode.
270
324
@@ -295,6 +349,7 @@ Translate world coordinates to [screen coordinates](#screen-coordinates) using t
295
349
**RETURN**
296
350
*`screen_coords` (vector3) Note: Same v3 object as passed in as argument
Add a custom projector that can be used by cameras in your project (see configuration above).
@@ -308,17 +363,10 @@ Add a custom projector that can be used by cameras in your project (see configur
308
363
Set a specific projector for a camera. This must be either one of the predefined projectors (see above) or a custom projector added using `camera.add_projector()`.
309
364
310
365
**PARAMETERS**
311
-
*`camera_id` (hash) - Id of the camera to set projector for.
366
+
*`camera_id` (hash|url|nil) nil for the first camera
312
367
*`projector_id` (hash) - Id of the projector.
313
368
314
-
315
-
### camera.set_window_size(width, height)
316
-
Set the current window size so that it is available to projectors via `camera.get_window_size()`. Set this via your render script.
Set window scaling factor (basically retina or no retina screen). There is no built-in way to detect if Defold is running on a retina or non retina screen. This information combined with the High DPI setting in game.project can be used to ensure that the zoom behaves the same way regardless of screen type and High DPI setting. You can use an extension such as [DefOS](https://github.com/subsoap/defos) to get the window scaling factor.
@@ -328,7 +376,7 @@ Set window scaling factor (basically retina or no retina screen). There is no bu
328
376
329
377
330
378
### camera.get_window_size()
331
-
Get the current window size, as it was provided by `camera.set_window_size()`. The default values will be the ones specified in game.project.
379
+
Get the current window size. The default values will be the ones specified in game.project.
332
380
333
381
**RETURN**
334
382
*`width` (number) - Current window width.
@@ -342,6 +390,8 @@ Get the display size, as specified in game.project.
342
390
*`width` (number) - Display width.
343
391
*`height` (number) - Display height.
344
392
393
+
---
394
+
345
395
## The Orthographic Camera API - messages
346
396
Most of the functions of the API have message equivalents that can be sent to the camera component.
0 commit comments