Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

VisibleOnScreenNotifier2D

繼承: Node2D < CanvasItem < Node < Object

被繼承: VisibleOnScreenEnabler2D

A rectangular region of 2D space that detects whether it is visible on screen.

說明

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 screen_entered signal, and likewise it will emit a screen_exited signal when no part of it remains visible.

If you want a node to be enabled automatically when this region is visible on screen, use VisibleOnScreenEnabler2D.

Note: VisibleOnScreenNotifier2D uses the render culling code to determine whether it's visible on screen, so it won't function unless CanvasItem.visible is set to true.

教學

屬性

Rect2

rect

Rect2(-10, -10, 20, 20)

bool

show_rect

true

方法

bool

is_on_screen() const


訊號

screen_entered() 🔗

當該 VisibleOnScreenNotifier2D 進入螢幕時發出。


screen_exited() 🔗

當該 VisibleOnScreenNotifier2D 退出螢幕時發出。


屬性說明

Rect2 rect = Rect2(-10, -10, 20, 20) 🔗

該 VisibleOnScreenNotifier2D 的邊界矩形。


bool show_rect = true 🔗

  • void set_show_rect(value: bool)

  • bool is_showing_rect()

If true, shows the rectangle area of rect in the editor with a translucent magenta fill. Unlike changing the visibility of the VisibleOnScreenNotifier2D, this does not affect the screen culling detection.


方法說明

bool is_on_screen() const 🔗

If true, the bounding rectangle is on the screen.

Note: It takes one frame for the VisibleOnScreenNotifier2D's visibility to be determined once added to the scene tree, so this method will always return false right after it is instantiated, before the draw pass.