Skip to content

Object

Object

Object()

Creates a new Object, not yet part of the scene — call add_object() to insert it.

children property

children: list[Object]

This Object's direct children

hidden property writable

hidden: bool

Whether this Object is hidden. Prefer show()/hide() over setting this directly.

id property

id: int

Unique id of this Object

name property writable

name: str

Display name of this Object

parent property

parent: Object

This Object's parent, or None if it has none

parent_id property

parent_id: int

Id of this Object's parent, or an invalid id if it has none

add_child

add_child(obj: Object) -> Object

Add obj as a child of this Object

add_component

add_component(component: Any) -> typing.Any

Attach a component instance to this Object.

Example
obj.add_component(RenderComponent)

add_object

add_object(obj: Object, parent: Object = None) -> Object

Add a newly created Object to the scene, optionally parented to another Object

get_children

get_children() -> list[Object]

Get children. See the children property.

get_children_count

get_children_count() -> int

Number of direct children this Object has

get_component

get_component(component_class: Any) -> typing.Any

Look up a component on this Object

get_parent

get_parent() -> Object

Get parent. See the parent property.

get_parent_id

get_parent_id() -> int

Get parent_id. See the parent_id property.

has_component

has_component(component: Any) -> bool

Check if this Object has a component of the given type.

Example
obj.has_component(RenderComponent)

hide

hide() -> None

Hide this Object

remove_component

remove_component(component_class: Any) -> None

Remove a component of the given type from this Object.

Example
obj.remove_component(RenderComponent)

remove_object

remove_object(obj: Object) -> None

Remove an object from the scene

set_name

set_name(name: str) -> None

Set name. See the name property.

show

show() -> None

Unhide this Object

get_all_objects

get_all_objects() -> list[Object]

Every Object currently in the scene. Useful for linear searches instead of maintaining your own registry.

Example
enemies = [o for o in get_all_objects() if o.has_component(Enemy)]

find_objects_with_component

find_objects_with_component(component_class: Any) -> list[Object]

Every Object in the scene that has the given component type.

Example
enemies = find_objects_with_component(Enemy)