feat(anim): animation ergonomics — named clips, Anim.play/Motion.to, frame events, fluent Tween handles (#48)
The ergonomic layer over the engine-owned SpriteAnim/Motion systems (#43): - Named clips: Anim.clip("run", frames, fps, mode) registers a clip by name and Anim.play(entity, "run") plays it; Anim.play(entity, fps, frames, mode) sets the clip directly. A name-keyed registry in systems.ludic. - Frame events: Anim.on_frame(entity, frame) arms optional SpriteAnim event_frame/event_fired fields; the engine flags the tick the clip first lands on that frame, and Anim.fired(entity) reads it — the game reacts, so it stays inside the no-runtime-dispatch event model. - Motion.to(entity, from, to, dur, ease) starts a value tween over the Motion component in one call (reflection-ABI writes, resetting the timer). - Fluent Tween handles (runtime/native/tween.ludic): Tween.to / Tween.chain / Tween.delay build a sequenced, disposable handle advanced by a new engine-owned system (esys_tween, run each Update tick); Tween.value / Tween.done / Tween.parallel / Tween.stop read and control it. The 1-arg Tween.done(handle) is disambiguated from the 2-arg pure Tween.done(timer, dur). Splicing: g_uses_anim_rt pulls in systems.ludic; g_uses_tween_rt pulls in tween.ludic and inserts esys_tween into the Update phase. All integer and deterministic, so animation and motion reproduce exactly under replay/lockstep. Worked example + regression: examples/library/anim_sugar.ludic (4 8 2 1 0 100 100 0 0 1 20 20 30 0 1). Twelve new docs pages (Anim, the new Motion namespace, Tween handles). Full suite 77 passed, self-host C-free fixpoint intact, no golden drift. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
382826889f
commit
1f5e3c1c1a
25 changed files with 24149 additions and 21866 deletions
30
docs/language/tween/tween-parallel.md
Normal file
30
docs/language/tween/tween-parallel.md
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
id: tween-parallel
|
||||
name: Tween.parallel
|
||||
category: tween
|
||||
kind: namespace-method
|
||||
tokens: Tween.parallel
|
||||
sig: Tween.parallel(a, b) -> bool
|
||||
tip: Are two tween handles both finished? — a parallel completion query.
|
||||
order: 35
|
||||
ns: Tween
|
||||
member: parallel
|
||||
---
|
||||
|
||||
Returns whether two <a href="tween-to"><code>handles</code></a> are <em>both</em> finished. Independent handles are advanced together every frame, so running several at once already runs them in parallel; this is the "wait for all" query over a pair — start a fade and a slide together, then act when both complete. For longer sequences on a single value, chain segments with <a href="tween-chain"><code>Tween.chain</code></a> instead.
|
||||
|
||||
Parameters:
|
||||
- `a`, `b` — the two tween handles to test
|
||||
|
||||
```ludic
|
||||
program Demo {
|
||||
property Marker { n: int = 0 }
|
||||
model M { Marker }
|
||||
entry {
|
||||
let fade = Tween.to(255, 0, 20, 0)
|
||||
let slide = Tween.to(0, 80, 30, 2)
|
||||
if Tween.parallel(fade, slide) { print(1) } # both done?
|
||||
quit()
|
||||
}
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue