ludic/motion-to.html
2026-09-17 22:10:03 +00:00

37 lines
No EOL
2.8 KiB
HTML
Raw Permalink 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>Motion.to — Ludic</title>
<meta name="description" content="Start a value tween on an entity&#x27;s Motion component 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-motion.html">Motion</a> <span>›</span> <span class="here">Motion.to</span></div>
<div class="item-head">
<span class="kind-badge kind-method">method</span>
<h1 id="top">Motion.to</h1>
</div>
<code class="sig">Motion.to(entity, from, to, dur, ease)</code>
<div class="desc"><p>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.</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>Motion</code></span></div><div class="param" id="param-dur"><code class="pname">dur</code><span class="pdesc">the duration in engine ticks</span></div><div class="param" id="param-ease"><code class="pname">ease</code><span class="pdesc">0 linear, 1 in, 2 out, 3 in-out</span></div></div>
<div class="examples"><h2>Example</h2><pre data-lang="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 -&gt; 64 over 30 ticks, ease-out
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>