class_visibilitynotifier2d.rst 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.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. Tutorials
  17. ---------
  18. - `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
  19. Properties
  20. ----------
  21. +---------------------------+-------------------------------------------------------+-------------------------------+
  22. | :ref:`Rect2<class_Rect2>` | :ref:`rect<class_VisibilityNotifier2D_property_rect>` | ``Rect2( -10, -10, 20, 20 )`` |
  23. +---------------------------+-------------------------------------------------------+-------------------------------+
  24. Methods
  25. -------
  26. +-------------------------+-----------------------------------------------------------------------------------------+
  27. | :ref:`bool<class_bool>` | :ref:`is_on_screen<class_VisibilityNotifier2D_method_is_on_screen>` **(** **)** |const| |
  28. +-------------------------+-----------------------------------------------------------------------------------------+
  29. Signals
  30. -------
  31. .. _class_VisibilityNotifier2D_signal_screen_entered:
  32. - **screen_entered** **(** **)**
  33. Emitted when the VisibilityNotifier2D enters the screen.
  34. ----
  35. .. _class_VisibilityNotifier2D_signal_screen_exited:
  36. - **screen_exited** **(** **)**
  37. Emitted when the VisibilityNotifier2D exits the screen.
  38. ----
  39. .. _class_VisibilityNotifier2D_signal_viewport_entered:
  40. - **viewport_entered** **(** :ref:`Viewport<class_Viewport>` viewport **)**
  41. Emitted when the VisibilityNotifier2D enters a :ref:`Viewport<class_Viewport>`'s view.
  42. ----
  43. .. _class_VisibilityNotifier2D_signal_viewport_exited:
  44. - **viewport_exited** **(** :ref:`Viewport<class_Viewport>` viewport **)**
  45. Emitted when the VisibilityNotifier2D exits a :ref:`Viewport<class_Viewport>`'s view.
  46. Property Descriptions
  47. ---------------------
  48. .. _class_VisibilityNotifier2D_property_rect:
  49. - :ref:`Rect2<class_Rect2>` **rect**
  50. +-----------+-------------------------------+
  51. | *Default* | ``Rect2( -10, -10, 20, 20 )`` |
  52. +-----------+-------------------------------+
  53. | *Setter* | set_rect(value) |
  54. +-----------+-------------------------------+
  55. | *Getter* | get_rect() |
  56. +-----------+-------------------------------+
  57. The VisibilityNotifier2D's bounding rectangle.
  58. Method Descriptions
  59. -------------------
  60. .. _class_VisibilityNotifier2D_method_is_on_screen:
  61. - :ref:`bool<class_bool>` **is_on_screen** **(** **)** |const|
  62. If ``true``, the bounding rectangle is on the screen.
  63. **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.
  64. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  65. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  66. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`