ludic/anim-clip.html
2026-09-17 22:10:03 +00:00

39 lines
No EOL
2.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Anim.clip — Ludic</title>
<meta name="description" content="Register a named spritesheet clip so Anim.play can play it by name.">
<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> <a href="ns-anim.html">Anim</a> <span>›</span> <span class="here">Anim.clip</span></div>
<div class="item-head">
<span class="kind-badge kind-method">method</span>
<h1 id="top">Anim.clip</h1>
</div>
<code class="sig">Anim.clip(name, frames, fps, mode)</code>
<div class="desc"><p>Registers (or updates) a spritesheet clip under a <code>name</code>, so gameplay refers to a motion by name — <code>Anim.play(entity, "run")</code> — instead of repeating its frame count and rate everywhere. The clip stores <code>frames</code> (cell count), <code>fps</code> (rate) and <code>mode</code> (0 loop, 1 once, 2 ping-pong). Names compare by identity (a string literal interns to one pointer), and the registry holds up to 32 clips. Registering the same name again overwrites it.</p></div>
<div class="params"><h2>Parameters</h2><div class="param" id="param-name"><code class="pname">name</code><span class="pdesc">the clip name (a string)</span></div><div class="param" id="param-frames"><code class="pname">frames</code><span class="pdesc">number of cells in the clip</span></div><div class="param" id="param-fps"><code class="pname">fps</code><span class="pdesc">playback rate in frames per second</span></div><div class="param" id="param-mode"><code class="pname">mode</code><span class="pdesc">0 loop, 1 once (clamp on last), 2 ping-pong</span></div></div>
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
property SpriteAnim { ticks: int = 0, fps: int = 0, frames: int = 0, mode: int = 0, frame: int = 0 }
model Hero { SpriteAnim }
entry {
Anim.clip("idle", 2, 4, 0) # a slow 2-frame idle loop
Anim.clip("run", 6, 12, 0) # a 6-frame run
Anim.clip("hit", 3, 15, 1) # a one-shot hit reaction
spawn Hero { SpriteAnim { } }
Anim.play(World.query_next(World.prop_id("SpriteAnim"), 0), "run")
quit()
}
}</pre></div>
<a class="back" href="api.html">← All symbols</a>
</main>
<script src="ludic-highlight.js"></script>
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
</body></html>