Skip to content

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

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.

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)
  • event VisibilityNotifierNodeEvent|string
  • handler fun(value: any, source: VisibilityNotifierNode)

Returns integer id Connection id for disconnect

Reads an Inspector property by its path (vectors and colours as tables); “script.” reads a field of the node’s script.

local value = self.node:get_property("size")
  • path VisibilityNotifierNodeProperty|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.” a field of the node’s script.

self.node:set_property("size", 100, 50)
  • path VisibilityNotifierNodeProperty|string
  • value any
  • y? number
{
"type": "VisibilityNotifierNode",
"name": "VisibilityNotifier",
"position": [
0,
0
],
"properties": {
"size": [
64,
64
],
"margin": 0,
"action": "None"
}
}