Object¶
Object ¶
Object()
Creates a new Object, not yet part of the scene — call add_object() to insert it.
hidden
property
writable
¶
hidden: bool
Whether this Object is hidden. Prefer show()/hide() over setting this directly.
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_component ¶
get_component(component_class: Any) -> typing.Any
Look up a component on this Object
has_component ¶
has_component(component: Any) -> bool
Check if this Object has a component of the given type.
Example
obj.has_component(RenderComponent)
remove_component ¶
remove_component(component_class: Any) -> None
Remove a component of the given type from this Object.
Example
obj.remove_component(RenderComponent)
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)