22 lines
No EOL
4.4 KiB
HTML
22 lines
No EOL
4.4 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Anim — Ludic</title>
|
||
<meta name="description" content="Spritesheet frame animation off the fixed frame clock.">
|
||
<link rel="stylesheet" href="base.css">
|
||
<link rel="stylesheet" href="docs.css">
|
||
</head>
|
||
<body>
|
||
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||
<main class="wrap item">
|
||
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <span class="here">Anim</span></div>
|
||
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">Anim</h1></div>
|
||
<p class="ns-blurb">Spritesheet frame animation off the fixed frame clock. Store an elapsed <code>timer</code> (seconds, a <code>fixed</code>) on a component and each frame ask <a href="anim-frame"><code>Anim.frame</code></a> / <a href="anim-once"><code>Anim.once</code></a> / <a href="anim-pingpong"><code>Anim.pingpong</code></a> which cell to draw; <a href="anim-cell_x"><code>Anim.cell_x</code></a>/<a href="anim-cell_y"><code>Anim.cell_y</code></a> turn a frame index into a source rectangle on the sheet. Everything is integer/fixed and deterministic — the same timer reproduces the same frame every run, so replays and lockstep netcode match exactly. For the ECS engine-owned <code>SpriteAnim</code> component there is also an ergonomic layer: register named clips with <a href="anim-clip"><code>Anim.clip</code></a> and play them by name with <a href="anim-play"><code>Anim.play</code></a>, and arm frame events with <a href="anim-on_frame"><code>Anim.on_frame</code></a> / <a href="anim-fired"><code>Anim.fired</code></a>.</p>
|
||
<div class="ns-methods"><a class="ns-method" href="anim-frame.html"><code class="nm-sig">Anim.frame(timer, fps, count) -> int</code><span class="nm-tip">The looping frame index for an elapsed timer at a given fps.</span></a><a class="ns-method" href="anim-once.html"><code class="nm-sig">Anim.once(timer, fps, count) -> int</code><span class="nm-tip">A non-looping frame index that clamps on the last frame.</span></a><a class="ns-method" href="anim-pingpong.html"><code class="nm-sig">Anim.pingpong(timer, fps, count) -> int</code><span class="nm-tip">A frame index that bounces 0..count-1..0 and repeats.</span></a><a class="ns-method" href="anim-finished.html"><code class="nm-sig">Anim.finished(timer, fps, count) -> bool</code><span class="nm-tip">True once a one-shot clip has run past its last frame.</span></a><a class="ns-method" href="anim-duration.html"><code class="nm-sig">Anim.duration(fps, count) -> fixed</code><span class="nm-tip">Seconds for one full cycle of a clip: count / fps.</span></a><a class="ns-method" href="anim-cell_x.html"><code class="nm-sig">Anim.cell_x(frame, cols, cell_w) -> int</code><span class="nm-tip">The source x (pixels) of a frame on a grid spritesheet.</span></a><a class="ns-method" href="anim-cell_y.html"><code class="nm-sig">Anim.cell_y(frame, cols, cell_h) -> int</code><span class="nm-tip">The source y (pixels) of a frame on a grid spritesheet.</span></a><a class="ns-method" href="anim-play.html"><code class="nm-sig">Anim.play(entity, clip) | Anim.play(entity, fps, frames, mode)</code><span class="nm-tip">Start (or restart) a spritesheet clip on an entity in one call.</span></a><a class="ns-method" href="anim-clip.html"><code class="nm-sig">Anim.clip(name, frames, fps, mode)</code><span class="nm-tip">Register a named spritesheet clip so Anim.play can play it by name.</span></a><a class="ns-method" href="anim-on_frame.html"><code class="nm-sig">Anim.on_frame(entity, frame)</code><span class="nm-tip">Arm a frame event — the engine flags the tick a clip lands on this frame.</span></a><a class="ns-method" href="anim-fired.html"><code class="nm-sig">Anim.fired(entity) -> bool</code><span class="nm-tip">Did the entity's clip land on its armed frame event this tick?</span></a></div>
|
||
<a class="back" href="api.html">← All symbols</a>
|
||
</main>
|
||
<script src="ludic-highlight.js"></script>
|
||
<script>Ludic.installCards(); Ludic.flashTarget();</script>
|
||
</body></html> |