Visibility Notifier
Knows when the camera sees a rectangle: screen_entered / screen_exited, and can pause, disable or remove its parent off screen (enemies wake up, bullets despawn).
Type: VisibilityNotifierNode · Category: Physics & Collision · Also found as: visibility, on screen, notifier
Properties
Section titled “Properties”| Property | Type | Default | Description |
|---|---|---|---|
size |
vec2 | (64, 64) |
The rectangle (centred on the node, scaled with it) the camera has to see. Range 1 to 4096. |
margin |
number | 0 |
Grows the camera’s view by this many pixels: fires a little before it really shows. Range 0 to 1024. |
action |
enum: None, Pause_Parent, Disable_Parent, Remove_Parent |
None |
What happens to the parent off screen: Pause (stops updating, resumes when seen), Disable (also stops drawing), Remove (freed once it was seen and left). |
onScreen |
boolean | false |
The camera sees it now (runtime, read-only). Runtime state: read-only, not saved. |
Plus the common properties every node has.
Lua methods
Section titled “Lua methods”Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.
VisibilityNotifierNode:connect(event, handler)
Section titled “VisibilityNotifierNode:connect(event, handler)”Connects a handler to one of this node’s events: screen_entered (The camera started seeing it), screen_exited (The camera stopped seeing it); the tree events; custom ones.
self.node:connect("screen_entered", function(value, source) Log.info("screen_entered") end)eventVisibilityNotifierNodeEvent|stringhandlerfun(value:any, source: VisibilityNotifierNode)
Returns integer id Connection id for disconnect
VisibilityNotifierNode:get_property(path)
Section titled “VisibilityNotifierNode:get_property(path)”Reads an Inspector property by its path (vectors and colours as tables); “script.
local value = self.node:get_property("size")pathVisibilityNotifierNodeProperty|string
Returns any
VisibilityNotifierNode:set_property(path, value, y)
Section titled “VisibilityNotifierNode:set_property(path, value, y)”Sets an Inspector property by its path: vectors as {x, y} or x, y; colours as {r, g, b[, a]} 0..1 or “#rrggbb[aa]”; enums by name; “script.
self.node:set_property("size", 100, 50)pathVisibilityNotifierNodeProperty|stringvalueanyy?number
In a scene file
Section titled “In a scene file”{ "type": "VisibilityNotifierNode", "name": "VisibilityNotifier", "position": [ 0, 0 ], "properties": { "size": [ 64, 64 ], "margin": 0, "action": "None" }}