class_visibilitynotifier2d.rst 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the VisibilityNotifier2D.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_VisibilityNotifier2D:
  6. VisibilityNotifier2D
  7. ====================
  8. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`VisibilityEnabler2D<class_VisibilityEnabler2D>`
  10. Detects approximately when the node is visible on screen.
  11. Description
  12. -----------
  13. The VisibilityNotifier2D detects when it is visible on the screen. It also notifies when its bounding rectangle enters or exits the screen or a viewport.
  14. If you want nodes to be disabled automatically when they exit the screen, use :ref:`VisibilityEnabler2D<class_VisibilityEnabler2D>` instead.
  15. **Note:** For performance reasons, VisibilityNotifier2D uses an approximate heuristic with precision determined by :ref:`ProjectSettings.world/2d/cell_size<class_ProjectSettings_property_world/2d/cell_size>`. If you need precise visibility checking, use another method such as adding an :ref:`Area2D<class_Area2D>` node as a child of a :ref:`Camera2D<class_Camera2D>` node.
  16. Properties
  17. ----------
  18. +---------------------------+-------------------------------------------------------+-------------------------------+
  19. | :ref:`Rect2<class_Rect2>` | :ref:`rect<class_VisibilityNotifier2D_property_rect>` | ``Rect2( -10, -10, 20, 20 )`` |
  20. +---------------------------+-------------------------------------------------------+-------------------------------+
  21. Methods
  22. -------
  23. +-------------------------+-----------------------------------------------------------------------------------------+
  24. | :ref:`bool<class_bool>` | :ref:`is_on_screen<class_VisibilityNotifier2D_method_is_on_screen>` **(** **)** |const| |
  25. +-------------------------+-----------------------------------------------------------------------------------------+
  26. Signals
  27. -------
  28. .. _class_VisibilityNotifier2D_signal_screen_entered:
  29. - **screen_entered** **(** **)**
  30. Emitted when the VisibilityNotifier2D enters the screen.
  31. ----
  32. .. _class_VisibilityNotifier2D_signal_screen_exited:
  33. - **screen_exited** **(** **)**
  34. Emitted when the VisibilityNotifier2D exits the screen.
  35. ----
  36. .. _class_VisibilityNotifier2D_signal_viewport_entered:
  37. - **viewport_entered** **(** :ref:`Viewport<class_Viewport>` viewport **)**
  38. Emitted when the VisibilityNotifier2D enters a :ref:`Viewport<class_Viewport>`'s view.
  39. ----
  40. .. _class_VisibilityNotifier2D_signal_viewport_exited:
  41. - **viewport_exited** **(** :ref:`Viewport<class_Viewport>` viewport **)**
  42. Emitted when the VisibilityNotifier2D exits a :ref:`Viewport<class_Viewport>`'s view.
  43. Property Descriptions
  44. ---------------------
  45. .. _class_VisibilityNotifier2D_property_rect:
  46. - :ref:`Rect2<class_Rect2>` **rect**
  47. +-----------+-------------------------------+
  48. | *Default* | ``Rect2( -10, -10, 20, 20 )`` |
  49. +-----------+-------------------------------+
  50. | *Setter* | set_rect(value) |
  51. +-----------+-------------------------------+
  52. | *Getter* | get_rect() |
  53. +-----------+-------------------------------+
  54. The VisibilityNotifier2D's bounding rectangle.
  55. Method Descriptions
  56. -------------------
  57. .. _class_VisibilityNotifier2D_method_is_on_screen:
  58. - :ref:`bool<class_bool>` **is_on_screen** **(** **)** |const|
  59. If ``true``, the bounding rectangle is on the screen.
  60. **Note:** It takes one frame for the node's visibility to be assessed once added to the scene tree, so this method will return ``false`` right after it is instantiated, even if it will be on screen in the draw pass.
  61. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  62. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  63. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`