docs: regenerate site from f094acfdb5
This commit is contained in:
commit
63c5ed9baf
975 changed files with 55427 additions and 0 deletions
64
kw-on.html
Normal file
64
kw-on.html
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>on enter / on exit — Ludic</title>
|
||||
<meta name="description" content="Scene lifecycle hooks that fire as a scene becomes active or is left.">
|
||||
<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="api.html#scenes">Scenes & layers</a> <span>›</span> <span class="here">on enter / on exit</span></div>
|
||||
<div class="item-head">
|
||||
<span class="kind-badge kind-keyword">keyword</span>
|
||||
<h1 id="top">on enter / on exit</h1>
|
||||
</div>
|
||||
<code class="sig">on enter { … } on exit { … }</code>
|
||||
<div class="desc"><p><code>on</code> introduces a scene's lifecycle hooks: <code>on enter { … }</code> runs once when the scene becomes active, and <code>on exit { … }</code> runs once as it is left. They are hooks, <b>not phases</b> — the place for per-scene setup and teardown that has no equivalent in a mode register. The start scene's <code>on enter</code> fires at boot right after the <code>Start</code> phase; on a <code>become Other</code> the current scene's <code>on exit</code> runs, the active scene switches, then the new scene's <code>on enter</code> runs. Use <code>on enter</code> to spawn the models a scene needs and reset its counters, and <code>on exit</code> to tidy up before leaving.</p></div>
|
||||
|
||||
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program SceneHookExample {
|
||||
property Position { column: int = 0, row: int = 0 }
|
||||
model Enemy { Position }
|
||||
|
||||
var elapsed_frames: int = 0
|
||||
|
||||
scene Overworld start {
|
||||
layer World {
|
||||
handler EnterBattle phase Update {
|
||||
if Input.key() == 'b' { become Battle }
|
||||
}
|
||||
handler DrawWorld phase Render {
|
||||
Screen.clear(Color.MidnightBlue)
|
||||
Screen.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scene Battle {
|
||||
on enter {
|
||||
elapsed_frames = 0
|
||||
spawn Enemy { Position { column: 8, row: 4 } }
|
||||
}
|
||||
on exit {
|
||||
for (any_position) in query [Position, {Enemy}] { despawn self() }
|
||||
}
|
||||
layer Fight {
|
||||
handler DrawBattle phase Render {
|
||||
Screen.clear(Color.Crimson)
|
||||
for (current_position) in query [Position, {Enemy}] {
|
||||
Screen.fill_rectangle(x: current_position.column * 16, y: current_position.row * 16, width: 16, height: 16, color: Color.White)
|
||||
}
|
||||
Screen.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}</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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue