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>
33 lines
1.3 KiB
Markdown
33 lines
1.3 KiB
Markdown
---
|
|
id: motion-to
|
|
name: Motion.to
|
|
category: motion
|
|
kind: namespace-method
|
|
tokens: Motion.to
|
|
sig: Motion.to(entity, from, to, dur, ease)
|
|
tip: Start a value tween on an entity's Motion component in one call.
|
|
order: 1
|
|
ns: Motion
|
|
member: to
|
|
---
|
|
|
|
Starts a value tween on an entity's <code>Motion</code> component: it sets <code>from</code>, <code>to</code>, <code>dur</code> and <code>ease</code>, resets the timer, and seeds <code>value</code> at <code>from</code>, so the engine interpolates <code>value</code> from <code>from</code> to <code>to</code> over <code>dur</code> ticks and latches <code>done</code> at the end. One call replaces setting five fields by hand — a health bar sliding, a door opening, an alpha fade. A no-op if the entity has no <code>Motion</code>. Integer and deterministic.
|
|
|
|
Parameters:
|
|
- `entity` — the entity carrying `Motion`
|
|
- `from`, `to` — the start and end values (integer game units)
|
|
- `dur` — the duration in engine ticks
|
|
- `ease` — 0 linear, 1 in, 2 out, 3 in-out
|
|
|
|
```ludic
|
|
program Demo {
|
|
property Motion { ticks: int = 0, dur: int = 0, from: int = 0, to: int = 0, ease: int = 0, value: int = 0, done: int = 0 }
|
|
model Door { Motion }
|
|
entry {
|
|
spawn Door { Motion { } }
|
|
let e = World.query_next(World.prop_id("Motion"), 0)
|
|
Motion.to(e, 0, 64, 30, 2) # slide 0 -> 64 over 30 ticks, ease-out
|
|
quit()
|
|
}
|
|
}
|
|
```
|