39 lines
No EOL
2.8 KiB
HTML
39 lines
No EOL
2.8 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Anim.play — Ludic</title>
|
||
<meta name="description" content="Start (or restart) a spritesheet clip on an entity in one call.">
|
||
<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.play</span></div>
|
||
<div class="item-head">
|
||
<span class="kind-badge kind-method">method</span>
|
||
<h1 id="top">Anim.play</h1>
|
||
</div>
|
||
<code class="sig">Anim.play(entity, clip) | Anim.play(entity, fps, frames, mode)</code>
|
||
<div class="desc"><p>Starts a spritesheet clip on an entity's <code>SpriteAnim</code> component and rewinds it to its first cell, so gameplay swaps or replays an animation with one call instead of setting five fields by hand. Two forms: <code>Anim.play(entity, "run")</code> plays a <a href="anim-clip"><code>named clip</code></a> registered with <code>Anim.clip</code>; <code>Anim.play(entity, fps, frames, mode)</code> sets the clip directly (<code>mode</code> 0 loop, 1 once, 2 ping-pong). A no-op if the entity has no <code>SpriteAnim</code>. The engine advances the clip from there each tick.</p></div>
|
||
<div class="params"><h2>Parameters</h2><div class="param" id="param-entity"><code class="pname">entity</code><span class="pdesc">the entity carrying <code>SpriteAnim</code></span></div><div class="param" id="param-clip"><code class="pname">clip</code><span class="pdesc">a registered clip name (2-argument form), **or**</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("run", 6, 12, 0)
|
||
spawn Hero { SpriteAnim { } }
|
||
let e = World.query_next(World.prop_id("SpriteAnim"), 0)
|
||
Anim.play(e, "run") # by name
|
||
Anim.play(e, 8, 4, 1) # or directly: 4 frames @ 8fps, once
|
||
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> |