39 lines
No EOL
2.9 KiB
HTML
39 lines
No EOL
2.9 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Tween.to — Ludic</title>
|
||
<meta name="description" content="Start a fluent, engine-advanced tween and return a handle.">
|
||
<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-tween.html">Tween</a> <span>›</span> <span class="here">Tween.to</span></div>
|
||
<div class="item-head">
|
||
<span class="kind-badge kind-method">method</span>
|
||
<h1 id="top">Tween.to</h1>
|
||
</div>
|
||
<code class="sig">Tween.to(from, to, dur, ease) -> handle</code>
|
||
<div class="desc"><p>Starts a <strong>stateful tween handle</strong> — from <code>from</code> to <code>to</code> over <code>dur</code> ticks with easing <code>ease</code> — and returns an integer handle. Unlike the pure <a href="tween-progress"><code>Tween.progress</code></a> interpolators (which the game drives from its own timer), a handle is <em>advanced by the engine</em> one tick per frame: fire it once, then read <a href="tween-value"><code>Tween.value</code></a> each frame and <a href="tween-done"><code>Tween.done</code></a> to know when it finishes. <a href="tween-chain"><code>Tween.chain</code></a> and <a href="tween-delay"><code>Tween.delay</code></a> append segments for a sequence. Integer and deterministic, so a sequence plays identically under replay. The handle pool is fixed-size and reuses finished slots.</p></div>
|
||
<div class="params"><h2>Parameters</h2><div class="param" id="param-dur"><code class="pname">dur</code><span class="pdesc">the segment length 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 SpriteAnim { ticks: int = 0, fps: int = 0, frames: int = 0, mode: int = 0, frame: int = 0 }
|
||
property Pop { h: int = 0 }
|
||
model Coin { SpriteAnim, Pop }
|
||
entry {
|
||
spawn Coin { Pop { h: 0 } }
|
||
let e = World.query_next(World.prop_id("Pop"), 0)
|
||
let f = World.field_id(World.prop_id("Pop"), "h")
|
||
World.set(e, World.prop_id("Pop"), f, Tween.to(0, 40, 20, 2)) # pop upward
|
||
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> |