simvx.core.nodes_2d.node2d

Node2D – 2D spatial node with position, rotation, and scale.

Module Contents

Classes

Node2D

2D spatial node with position, rotation, and scale.

API

class simvx.core.nodes_2d.node2d.Node2D(position=None, rotation: float = 0.0, scale=None, **kwargs)[source]

Bases: simvx.core.node.Node

2D spatial node with position, rotation, and scale.

Extends Node with a 2D transform (position, rotation, scale) and cached world-transform propagation. All spatial 2D nodes – sprites, cameras, collision shapes – inherit from this.

Attributes: position: Local position as Vec2 (pixels). rotation: Local rotation in radians (float). scale: Local scale as Vec2 (default (1, 1)). z_index: Draw order relative to siblings (higher = on top). z_as_relative: When True (default), z_index is added to the parent’s absolute z-index.

Example::

player = Node2D(position=(100, 200), rotation=0.0, name="Player")
player.position += Vec2(10, 0)
print(player.world_position)

Initialization

z_index

‘Property(…)’

z_as_relative

‘Property(…)’

render_layer

‘Property(…)’

set_render_layer(index: int, enabled: bool = True) None[source]

Enable or disable a specific render layer (0-31).

is_on_render_layer(index: int) bool[source]

Check if this node is on a specific render layer (0-31).

property absolute_z_index: int

Compute absolute z-index walking up the tree (cached).

property position: simvx.core.math.types.Vec2
property rotation: float

Local rotation in radians.

property rotation_degrees: float

Local rotation in degrees (convenience for editor display).

property scale: simvx.core.math.types.Vec2
property world_position: simvx.core.math.types.Vec2
property world_rotation: float

World rotation in radians.

property world_scale: simvx.core.math.types.Vec2
property forward: simvx.core.math.types.Vec2

Unit vector pointing in the direction of rotation (up = -Y in screen coords).

property right: simvx.core.math.types.Vec2
translate(offset: tuple[float, float] | numpy.ndarray)[source]
rotate(radians: float)[source]

Rotate by the given number of radians.

rotate_deg(degrees: float)[source]

Rotate by the given number of degrees.

look_at(target: tuple[float, float] | numpy.ndarray)[source]
transform_points(points: list[simvx.core.math.types.Vec2]) list[simvx.core.math.types.Vec2][source]

Transform local points by this node’s position and rotation.

draw_polygon(renderer, points: list[simvx.core.math.types.Vec2], closed=True, colour=None)[source]

Draw a polygon transformed by this node’s position/rotation.

wrap_screen(margin: float = 20)[source]

Wrap position around screen edges.

strict_errors: ClassVar[bool]

True

script_error_raised

‘Signal(…)’

classmethod __init_subclass__(**kwargs)
property name: str
property process_mode: simvx.core.descriptors.ProcessMode
reset_error() None
add_child(node: simvx.core.node.Node) simvx.core.node.Node
remove_child(node: simvx.core.node.Node)
reparent(new_parent: simvx.core.node.Node)
get_node(path: str) simvx.core.node.Node
find_child(name: str, recursive: bool = False) simvx.core.node.Node | None
find(node_type: type, recursive: bool = True) simvx.core.node.Node | None
find_all(node_type: type, recursive: bool = True) list
property path: str
add_to_group(group: str)
remove_from_group(group: str)
is_in_group(group: str) bool
ready() None
enter_tree() None
exit_tree() None
process(dt: float) None
physics_process(dt: float) None
draw(renderer) None
input_event(event: simvx.core.events.InputEvent) None
input(event: simvx.core.events.TreeInputEvent) None
unhandled_input(event: simvx.core.events.TreeInputEvent) None
start_coroutine(gen: simvx.core.descriptors.Coroutine) simvx.core.descriptors.CoroutineHandle
stop_coroutine(gen_or_handle)
clear_children()
destroy()
property app
property tree: simvx.core.scene_tree.SceneTree
get_tree() simvx.core.scene_tree.SceneTree
__getitem__(key: str)
classmethod get_properties() dict[str, simvx.core.descriptors.Property]
__repr__()