0.2.0-dev Download ZIP
43 lines ·2.4 KB Raw
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="VisibleOnScreenNotifier2D" inherits="Node2D" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | A rectangular region of 2D space that detects whether it is visible on screen. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | [VisibleOnScreenNotifier2D] represents a rectangular region of 2D space. When any part of this region becomes visible on screen or in a viewport, it will emit a [signal screen_entered] signal, and likewise it will emit a [signal screen_exited] signal when no part of it remains visible. |
| 8 | If you want a node to be enabled automatically when this region is visible on screen, use [VisibleOnScreenEnabler2D]. |
| 9 | [b]Note:[/b] [VisibleOnScreenNotifier2D] uses the render culling code to determine whether it's visible on screen, so it won't function unless [member CanvasItem.visible] is set to [code]true[/code]. |
| 10 | </description> |
| 11 | <tutorials> |
| 12 | <link title="2D Dodge The Creeps Demo">https://godotengine.org/asset-library/asset/2712</link> |
| 13 | </tutorials> |
| 14 | <methods> |
| 15 | <method name="is_on_screen" qualifiers="const"> |
| 16 | <return type="bool" /> |
| 17 | <description> |
| 18 | If [code]true[/code], the bounding rectangle is on the screen. |
| 19 | [b]Note:[/b] It takes one frame for the [VisibleOnScreenNotifier2D]'s visibility to be determined once added to the scene tree, so this method will always return [code]false[/code] right after it is instantiated, before the draw pass. |
| 20 | </description> |
| 21 | </method> |
| 22 | </methods> |
| 23 | <members> |
| 24 | <member name="rect" type="Rect2" setter="set_rect" getter="get_rect" default="Rect2(-10, -10, 20, 20)"> |
| 25 | The VisibleOnScreenNotifier2D's bounding rectangle. |
| 26 | </member> |
| 27 | <member name="show_rect" type="bool" setter="set_show_rect" getter="is_showing_rect" default="true"> |
| 28 | If [code]true[/code], shows the rectangle area of [member rect] in the editor with a translucent magenta fill. Unlike changing the visibility of the VisibleOnScreenNotifier2D, this does not affect the screen culling detection. |
| 29 | </member> |
| 30 | </members> |
| 31 | <signals> |
| 32 | <signal name="screen_entered"> |
| 33 | <description> |
| 34 | Emitted when the VisibleOnScreenNotifier2D enters the screen. |
| 35 | </description> |
| 36 | </signal> |
| 37 | <signal name="screen_exited"> |
| 38 | <description> |
| 39 | Emitted when the VisibleOnScreenNotifier2D exits the screen. |
| 40 | </description> |
| 41 | </signal> |
| 42 | </signals> |
| 43 | </class> |