Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content
Edit this page

Tweens

Pite includes runtime-managed property and callback tweens for smooth animations, UI transitions, and timed sequences without manual timer boilerplate.

t = pite.tween()
t.property(self, "position", (200.0, 100.0), 0.5).ease("out").trans("cubic")
t.parallel().property(self, "modulate", "#ffffff80", 0.5)
t.callback(lambda: print("done!"))

Creating & Sequencing Tweens

  • pite.tween() -> Tween: Creates a new runtime-managed sequential tween. Steps added to a Tween execute one after another by default.
  • .parallel(): Makes the next step run concurrently with the previous step instead of waiting for it to finish.
  • .property(target, prop: str, final_val, duration: float) -> PropertyTweener: Interpolates prop on target over duration seconds. Supports:
    • float / int
    • Vec2 or (x, y) tuples (e.g., "position", "scale")
    • Color, (r, g, b, a) tuples, or #rrggbbaa hex strings (e.g., "modulate")
  • .callback(fn, delay: float = 0.0): Invokes fn after an optional delay.
  • .interval(duration: float): Waits for duration seconds before advancing to the next step.
  • .loops(count: int): Repeats the tween count times (0 = infinite).
  • .on_finished(fn): Registers a callback invoked when the entire tween finishes.

Easing & Transitions

property(...) returns a PropertyTweener with chainable configuration methods:

  • .ease(mode: str): "in", "out", "in_out", or "out_in".
  • .trans(curve: str): "linear", "quad", "cubic", "sine", "back", "bounce", or "elastic".
  • .from_(val): Overrides the starting value instead of reading the node's current property value when the step begins.
  • .delay(seconds: float): Delays the start of this property interpolation.

Playback Control & Lifecycle

  • .pause() / .play(): Pauses or resumes the tween.
  • .stop(): Stops the tween and resets it.
  • .kill(): Immediately cancels and removes the tween.
  • .is_running() -> bool: Returns True while the tween is active.

Missing target nodes are skipped cleanly, finished tweens are removed automatically, and all active tweens are cleared when the scene is reloaded or stopped.