simvx.core.animation.state_machine¶
Animation state machine with parameter-based transitions.
Module Contents¶
Classes¶
Single state in animation state machine. |
|
Transition between animation states. |
|
Animation state machine with parameter-based transitions. |
Data¶
API¶
- simvx.core.animation.state_machine.log¶
‘getLogger(…)’
- class simvx.core.animation.state_machine.AnimationState[source]¶
Single state in animation state machine.
- name: str¶
None
- clip: simvx.core.animation.track.AnimationClip¶
None
- speed_scale: float¶
1.0
- loop: bool¶
True
- class simvx.core.animation.state_machine.Transition[source]¶
Transition between animation states.
- from_state: str¶
None
- to_state: str¶
None
- condition: collections.abc.Callable[[], bool]¶
None
- blend_time: float¶
0.2
- class simvx.core.animation.state_machine.AnimationTree(**kwargs)[source]¶
Bases:
simvx.core.node.NodeAnimation state machine with parameter-based transitions.
As a Node subclass, it participates in the scene tree and gets
on_update(dt)called automatically. By default it animates its parent.Properties: target: The node whose properties are animated. Defaults to
parentwhen it is left unset.Attributes: states: Registered
AnimationStateobjects keyed by name. Each holds anAnimationClip, which has no source form, so a saved scene does not carry the states and they are rebuilt by the code that added them. transitions: RegisteredTransitionobjects. Each holds aCallablecondition, so these are not carried by a save either. parameters: The gameplay values transition conditions read, written through :meth:set_parameter. Runtime state. current_state, current_time, playing: Playback state. blending, blend_from, blend_to, blend_time, blend_duration: Transition state.blend_durationis the length of the crossfade now in flight, copied from theblend_timethe transition declared, so it says nothing about a tree that is not mid-transition.Example: tree = AnimationTree(target=player) tree.add_state(“idle”, idle_clip, loop=True) tree.add_state(“run”, run_clip, loop=True) tree.add_state(“jump”, jump_clip, loop=False)
tree.add_transition("idle", "run", lambda: tree.parameters["speed"] > 0.1) tree.add_transition("run", "idle", lambda: tree.parameters["speed"] < 0.1) tree.add_transition("idle", "jump", lambda: tree.parameters["jump_pressed"]) tree.set_parameter("speed", 0.0) tree.start("idle")Initialization
- target¶
‘Property(…)’
- __transient__¶
‘frozenset(…)’
- add_state(name: str, clip: simvx.core.animation.track.AnimationClip, speed_scale: float = 1.0, loop: bool = True)[source]¶
Add animation state.
- add_transition(from_state: str, to_state: str, condition: collections.abc.Callable[[], bool], blend_time: float = 0.2)[source]¶
Add transition with condition function.
- strict_errors: ClassVar[bool]¶
True
- dev_checks: ClassVar[bool]¶
None
- script_error_raised¶
‘Signal(…)’
- dynamic: bool¶
False
- visible¶
‘Property(…)’
- update_mode¶
‘Property(…)’
- __properties__: ClassVar[dict[str, simvx.core.descriptors.Property]]¶
None
- classmethod __init_subclass__(**kwargs)¶
- property name: str¶
- property visible_in_tree: bool¶
- reset_error() None¶
- add_child(node: simvx.core.node.T) simvx.core.node.T¶
- remove_child(node: simvx.core.node.Node) None¶
- reparent(new_parent: simvx.core.node.Node)¶
- node_at(path, default=_NO_DEFAULT)¶
- find(target, *, direct: bool = False)¶
- find_all(target, *, direct: bool = False)¶
- expect(target, *, direct: bool = False)¶
- ancestor(target)¶
- walk(*, include_self: bool = True) collections.abc.Iterator[simvx.core.node.Node]¶
- property path: str¶
- property is_scene_root: bool¶
- add_to_group(group: str)¶
- remove_from_group(group: str)¶
- is_in_group(group: str) bool¶
- on_ready() None¶
- on_enter_tree() None¶
- on_exit_tree() None¶
- on_fixed_update(dt: float) None¶
- on_draw(renderer) None¶
- on_picked(event: simvx.core.events.InputEvent) None¶
- on_unhandled_input(event: simvx.core.events.TreeInputEvent) None¶
- start_coroutine(gen: simvx.core.descriptors.Coroutine) simvx.core.descriptors.CoroutineHandle¶
- stop_coroutine(gen_or_handle)¶
- queue_redraw() None¶
- property render_dirty: bool¶
- clear_children()¶
- destroy()¶
- property destroying: bool¶
- call_deferred(method: collections.abc.Callable[..., Any], *args: Any) None¶
- property app¶
- property tree: simvx.core.scene_tree.SceneTree¶
- property physics¶
- property physics_2d¶
- __getitem__(key: str)¶
- classmethod get_properties() dict[str, simvx.core.descriptors.Property]¶
- __repr__()¶