incanto 0.69.0 → 0.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/_behaviors-loader.mjs +22 -0
- package/bin/_read-json.mjs +28 -0
- package/bin/incanto-assets.mjs +5 -4
- package/bin/incanto-check.mjs +58 -31
- package/bin/incanto-editor.mjs +128 -5
- package/bin/incanto-env.mjs +3 -2
- package/bin/incanto-feel.mjs +24 -13
- package/bin/incanto-frame.mjs +8 -1
- package/bin/incanto-multiplay.mjs +11 -9
- package/bin/incanto-new.mjs +105 -10
- package/bin/incanto-play.mjs +158 -16
- package/bin/incanto-playtest.mjs +66 -23
- package/bin/incanto-skills.mjs +14 -2
- package/bin/incanto-verify.mjs +125 -44
- package/bin/incanto.mjs +3 -2
- package/dist/2d.d.ts +281 -34
- package/dist/2d.js +4 -4
- package/dist/3d.d.ts +157 -9
- package/dist/3d.js +7 -7
- package/dist/{agent8-CvsfVskX.js → agent8-CmNF01gA.js} +61 -8
- package/dist/{audio-player-C0j2k-yB.d.ts → audio-player-DaMxqfNE.d.ts} +2 -2
- package/dist/{behavior-rm8vVzu_.d.ts → behavior-DZExDn9o.d.ts} +744 -46
- package/dist/{create-game-CwxEDlCm.js → create-game-Bwvh6q8A.js} +142 -59
- package/dist/{create-game-CvJ1wSRP.js → create-game-C7ffQWW7.js} +97 -47
- package/dist/debug.d.ts +1 -1
- package/dist/debug.js +2 -3
- package/dist/diagnostics-Cu85N3tL.d.ts +12 -0
- package/dist/{editor-switch-CnIOiyNJ.d.ts → editor-switch-CFU9mCec.d.ts} +22 -13
- package/dist/editor.js +1065 -863
- package/dist/env.d.ts +1 -1
- package/dist/env.js +5 -3
- package/dist/{environment-presets-BO-7XoFV.js → environment-presets-D6Q5BxeE.js} +298 -45
- package/dist/{gameplay-D1KixWK8.js → gameplay-BfHkuzVb.js} +809 -211
- package/dist/gameplay.d.ts +187 -7
- package/dist/gameplay.js +1 -1
- package/dist/{heightmap-CRK0M4jT.js → heightmap-BYgD5Edk.js} +1 -1
- package/dist/index.d.ts +156 -13
- package/dist/index.js +10 -12
- package/dist/json-CfTjpvW8.js +67 -0
- package/dist/{loader-DadV2QCT.d.ts → loader-Cff09LMm.d.ts} +2 -2
- package/dist/net.d.ts +27 -3
- package/dist/net.js +2 -2
- package/dist/{noise-CGUMx44x.js → noise-D3nPpmFg.js} +1 -1
- package/dist/{physics-2d-CF5yyjbj.js → physics-2d-CE0Qvy3V.js} +136 -11
- package/dist/{physics-3d-DbYaEcZy.js → physics-3d-CpH-2gn5.js} +104 -23
- package/dist/{teardown-CMqFVxO9.js → picking-CQJ_PJKh.js} +103 -12
- package/dist/react.d.ts +2 -2
- package/dist/react.js +2 -2
- package/dist/{register-mmfugpaQ.js → register-6DYnKZcy.js} +546 -817
- package/dist/{register-DbVArsns.js → register-Bkk0wSDB.js} +332 -23
- package/dist/{replay-BEHLDcQV.js → replay-DjAkAzMq.js} +224 -14
- package/dist/{replay-BQfkX4x7.d.ts → replay-Dmw-PKQu.d.ts} +20 -3
- package/dist/{schema-B6ugCV1Q.d.ts → rng-Bb-IutXB.d.ts} +38 -21
- package/dist/{rng-DP-SR7eg.js → rng-CDOMybym.js} +22 -0
- package/dist/{loader-DZE7B07H.js → save-slots-BXVg148r.js} +4570 -2322
- package/dist/{split-screen-Cg76MCV5.d.ts → split-screen--k-XpBjr.d.ts} +36 -4
- package/dist/{split-screen-CauMwu6y.js → split-screen-PL78oVXP.js} +159 -26
- package/dist/{sprite-animation-CY-mrr1L.js → sprite-animation-CqR2o3SA.js} +39 -8
- package/dist/{src-CYEu-_S9.js → src-Cxfiv1Hg.js} +2 -17
- package/dist/test-iHYVUcDK.js +4036 -0
- package/dist/test.d.ts +531 -30
- package/dist/test.js +3 -3
- package/dist/touch-BnCyPA0G.js +519 -0
- package/dist/vite.d.ts +20 -37
- package/dist/vite.js +176 -6
- package/dist/{webgl-unavailable-Z5_g8x9H.js → webgl-unavailable-C8aDbGmR.js} +44 -0
- package/editor/assets/agent8-D0MS174y.js +1 -0
- package/editor/assets/{debug-CMULinBW.js → debug-BnXkKuYu.js} +2 -2
- package/editor/assets/index-CIu3uc3l.js +11046 -0
- package/editor/index.html +1 -1
- package/package.json +4 -14
- package/schemas/scene.schema.json +30 -3
- package/skills/incanto-3d-character.md +14 -1
- package/skills/incanto-3d-models.md +12 -0
- package/skills/incanto-assets.md +9 -1
- package/skills/incanto-audio.md +8 -2
- package/skills/incanto-behaviors-and-scripts.md +83 -6
- package/skills/incanto-building-2d-games.md +77 -8
- package/skills/incanto-building-3d-games.md +58 -4
- package/skills/incanto-editor.md +46 -7
- package/skills/incanto-environment.md +19 -1
- package/skills/incanto-game-feel.md +70 -0
- package/skills/incanto-gameplay-behaviors.md +109 -19
- package/skills/incanto-hud.md +128 -7
- package/skills/incanto-localization.md +13 -5
- package/skills/incanto-multiplayer.md +83 -3
- package/skills/incanto-node-reference.md +222 -58
- package/skills/incanto-performance.md +52 -0
- package/skills/incanto-physics-and-input.md +123 -24
- package/skills/incanto-playtesting.md +78 -2
- package/skills/incanto-save-slots.md +161 -6
- package/skills/incanto-scene-json-authoring.md +69 -12
- package/skills/incanto-verifying-your-game.md +196 -10
- package/skills/incanto-web-integration.md +28 -0
- package/skills/incanto-your-first-game.md +3 -1
- package/templates-app/beacon-isle-3d/generate-world.ts +77 -9
- package/templates-app/beacon-isle-3d/package.json +2 -2
- package/templates-app/beacon-isle-3d/src/behaviors.ts +22 -0
- package/templates-app/beacon-isle-3d/src/game.scene.json +103 -378
- package/templates-app/beacon-isle-3d/src/main.ts +11 -1
- package/templates-app/beacon-isle-3d/tsconfig.json +1 -1
- package/templates-app/beacon-isle-3d/verify.ts +3 -1
- package/templates-app/molehill-2d/.incanto/playtest/lost-seed1.json +4277 -0
- package/templates-app/molehill-2d/PROJECT/Context.md +58 -0
- package/templates-app/molehill-2d/PROJECT/Requirements.md +39 -0
- package/templates-app/molehill-2d/PROJECT/Status.md +27 -0
- package/templates-app/molehill-2d/PROJECT/Structure.md +48 -0
- package/templates-app/molehill-2d/docs/project-2d-rules.md +44 -0
- package/templates-app/molehill-2d/index.html +73 -0
- package/templates-app/molehill-2d/package.json +23 -0
- package/templates-app/molehill-2d/src/behaviors.ts +198 -0
- package/templates-app/molehill-2d/src/game.scene.json +1255 -0
- package/templates-app/molehill-2d/src/main.ts +41 -0
- package/templates-app/molehill-2d/tsconfig.json +13 -0
- package/templates-app/molehill-2d/verify.ts +247 -0
- package/templates-app/molehill-2d/vite.config.ts +12 -0
- package/templates-app/platformer-2d/package.json +2 -2
- package/templates-app/platformer-2d/src/game.scene.json +128 -600
- package/templates-app/platformer-2d/src/main.ts +11 -1
- package/templates-app/platformer-2d/tsconfig.json +1 -1
- package/templates-app/star-survivor/package.json +2 -2
- package/templates-app/star-survivor/src/game.scene.json +41 -195
- package/templates-app/star-survivor/src/main.ts +11 -1
- package/templates-app/star-survivor/tsconfig.json +1 -1
- package/templates-app/tps-3d/PROJECT/Context.md +1 -1
- package/templates-app/tps-3d/package.json +2 -2
- package/templates-app/tps-3d/src/behaviors.ts +19 -1
- package/templates-app/tps-3d/src/game.scene.json +78 -217
- package/templates-app/tps-3d/src/main.ts +13 -2
- package/templates-app/tps-3d/tsconfig.json +1 -1
- package/templates-app/village-quest-3d/.incanto/playtest/swapped-seed1.json +1735 -0
- package/templates-app/village-quest-3d/package.json +2 -2
- package/templates-app/village-quest-3d/src/behaviors.ts +21 -0
- package/templates-app/village-quest-3d/src/grove.scene.json +54 -221
- package/templates-app/village-quest-3d/src/main.ts +11 -1
- package/templates-app/village-quest-3d/src/village.scene.json +199 -838
- package/templates-app/village-quest-3d/tsconfig.json +1 -1
- package/templates-app/village-quest-3d/verify.ts +14 -1
- package/dist/duplicate-Dj4L-5AA.js +0 -22
- package/dist/json-CwwhxQgb.js +0 -36
- package/dist/registry-CF70EArN.js +0 -212
- package/dist/rolldown-runtime-D7D4PA-g.js +0 -13
- package/dist/test-D6ISmuFE.js +0 -2383
- package/dist/touch-DEAmqGdf.js +0 -225
- package/editor/assets/agent8-BDvaZMQJ.js +0 -1
- package/editor/assets/index-CZIRr5EL.js +0 -10958
package/skills/incanto-editor.md
CHANGED
|
@@ -18,8 +18,20 @@ bunx incanto-editor level.scene.json --output build/level.scene.json --port 5179
|
|
|
18
18
|
|
|
19
19
|
**Project mode** (no file argument — the usual way) scans the current directory for
|
|
20
20
|
`*.scene.json` (skipping node_modules/dist/hidden dirs): one scene auto-opens; several
|
|
21
|
-
open the scene browser.
|
|
22
|
-
|
|
21
|
+
open the scene browser.
|
|
22
|
+
|
|
23
|
+
**What the server will and will not touch**, since the browser lists every
|
|
24
|
+
`.json` and the answer comes from the server:
|
|
25
|
+
|
|
26
|
+
| | |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| reads | any `.json` **under the launch directory** — but only sends it if it IS a scene; anything else comes back with the reason and its contents never leave |
|
|
29
|
+
| writes | a scene, over a file that is already a scene, or to a file that does not exist yet |
|
|
30
|
+
| refuses | a path outside the project, a non-scene body, and **overwriting a file that is not a scene** — `?file=package.json` gets a 409 naming what it found |
|
|
31
|
+
|
|
32
|
+
That last row used to be missing: the write path checked the body and never what
|
|
33
|
+
it was about to land on, so one query parameter could replace a manifest with a
|
|
34
|
+
scene. The GET on the same endpoint already refused it.
|
|
23
35
|
|
|
24
36
|
### The scene browser (`scenes`)
|
|
25
37
|
|
|
@@ -108,7 +120,13 @@ Opens a local page (default `http://127.0.0.1:5179/`) with three panes:
|
|
|
108
120
|
changed. A prop is rewritten only if its type declares `nodePath: true`, so a
|
|
109
121
|
text prop that merely reads "Player" is never touched. `+` adds a child of any registered
|
|
110
122
|
type, `✕` deletes the selection. Selecting the ⚙ scene row edits the header
|
|
111
|
-
(dimension, gravity with real inputs, environment/input/assets/multiplayer
|
|
123
|
+
(dimension, gravity with real inputs, environment/input/assets/multiplayer),
|
|
124
|
+
including a **STRINGS table** — one row per `@t:` key, one column per
|
|
125
|
+
language. It shows the two things raw JSON cannot: an untranslated cell shows
|
|
126
|
+
the English it will silently fall back to (greyed, because that fallback is
|
|
127
|
+
the design), and a key the BASE locale is missing is marked in red, because
|
|
128
|
+
that one has nothing to fall back to and paints the raw key on screen.
|
|
129
|
+
`+ key`, `+ language`, and deleting a key that a prop still says asks first.
|
|
112
130
|
- **CONNECTIONS on the selected node** — the inspector's last section shows what
|
|
113
131
|
the node **emits** and what it **receives**, each row being signal → target →
|
|
114
132
|
handler with a ✕ to remove and `+ connect` to add. Signals come from the node
|
|
@@ -116,8 +134,12 @@ Opens a local page (default `http://127.0.0.1:5179/`) with three panes:
|
|
|
116
134
|
node in the scene; the handler is a dropdown of real methods when the target
|
|
117
135
|
has no script, and free text when it does (those handlers live in your
|
|
118
136
|
TypeScript, which the editor never loads). An end that no longer resolves is
|
|
119
|
-
marked red with the reason. For what a row cannot express — `filter
|
|
120
|
-
|
|
137
|
+
marked red with the reason. For what a row cannot express — `filter` and `once`
|
|
138
|
+
— the scene header still has `connections` as raw JSON. (It used to say "bound
|
|
139
|
+
args" as well: a connection has never had them. Its keys are exactly
|
|
140
|
+
`[signal, from, to, handler, once, filter]`, and since they became a closed
|
|
141
|
+
set an invented one is a load error rather than a key that quietly does
|
|
142
|
+
nothing.)
|
|
121
143
|
**Validation now runs WITH connections**: the editor used to strip them before
|
|
122
144
|
loading, so it reported green for a scene the game hard-fails to open.
|
|
123
145
|
- **Viewport with DIRECT MANIPULATION** — a mode toolbar (top left) + the
|
|
@@ -167,8 +189,11 @@ Opens a local page (default `http://127.0.0.1:5179/`) with three panes:
|
|
|
167
189
|
`invulnerableFor`/`freeOnDeath` with their defaults; a `Patrol`'s `mode` is a
|
|
168
190
|
`loop`/`pingpong` menu), delta-only like every other field. A name that is NOT
|
|
169
191
|
built in is your game's TypeScript: it keeps the raw-JSON props box and says
|
|
170
|
-
so, with copy-paste Behavior boilerplate in its help —
|
|
171
|
-
|
|
192
|
+
so, with copy-paste Behavior boilerplate in its help — `groups` (name chips)
|
|
193
|
+
and `tags` (the node's free-form identity JSON: what
|
|
194
|
+
`connections[].filter.tag` matches on, and where a chart, a card or a loot
|
|
195
|
+
entry lives; a value the loader would reject is marked invalid rather than
|
|
196
|
+
written). Every one has a `?` help popover with examples. Values equal to the
|
|
172
197
|
default are removed (delta-only, like the serializer).
|
|
173
198
|
**A prop that holds a NODE PATH** (`Chase.target`, `Camera2D.follow`,
|
|
174
199
|
`Spawner.prefab`, `Joint3D.target`, `skinPath`, `terrain`…) offers every node
|
|
@@ -358,6 +383,20 @@ editing wherever the simulation happened to be. Games hosting the editor
|
|
|
358
383
|
themselves (`createGame3D({ editor: … })`) get a **save** button only when they
|
|
359
384
|
pass `editor.save` — otherwise edits live as long as the session does.
|
|
360
385
|
|
|
386
|
+
**The handle you booted with does not survive the round trip.** ▶ builds a NEW
|
|
387
|
+
game, so after one ✎→▶ the `game` your app is holding refers to something that
|
|
388
|
+
no longer exists. It is inert rather than destructive — a stale `dispose()` and
|
|
389
|
+
a stale `openEditor()` both do nothing — but if your app keeps using the handle,
|
|
390
|
+
take the live one:
|
|
391
|
+
|
|
392
|
+
```ts
|
|
393
|
+
let game = await createGame3D({
|
|
394
|
+
scene, canvas,
|
|
395
|
+
debug: DEBUG,
|
|
396
|
+
editor: DEBUG && { library: true, onReboot: (next) => { game = next; } },
|
|
397
|
+
});
|
|
398
|
+
```
|
|
399
|
+
|
|
361
400
|
## Animating a model from the inspector
|
|
362
401
|
|
|
363
402
|
Select a `ModelInstance3D` and everything about what it is DOING sits in one
|
|
@@ -201,6 +201,24 @@ template). Options: `seed`, `size` (32 blocks), `height` (8), `water`. The
|
|
|
201
201
|
voxel `generateIsland` (radial dome falloff, sandy shore) also remains for
|
|
202
202
|
the same use case.
|
|
203
203
|
|
|
204
|
+
**Digging and building** is the node's own API, and for a long time none of it
|
|
205
|
+
was written down here — the whole point of a voxel world is that it changes:
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
const world = this.node.getNode('World') as VoxelGrid3D;
|
|
209
|
+
world.tileAt(x, y, z); // the tile there, or undefined
|
|
210
|
+
world.removeBlockAt(x, y, z); // dig — true if there was one
|
|
211
|
+
world.addBlock({ x, y, z, tile: 3 });
|
|
212
|
+
world.setBlocks(blocks); // replace the lot (emits `blocksChanged`)
|
|
213
|
+
world.blockCount(); // how many are standing
|
|
214
|
+
world.blocks(); // every one of them, to save or inspect
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Grid coordinates, not world ones — multiply by the node's `blockSize` to place
|
|
218
|
+
something on a block. `TileMap2D` answers the same questions in two dimensions
|
|
219
|
+
(`cellAt`/`tileAt`/`worldAt`/`setTile`), and that one takes WORLD coordinates
|
|
220
|
+
because a flat world has a cursor in it.
|
|
221
|
+
|
|
204
222
|
## Library
|
|
205
223
|
|
|
206
224
|
```ts
|
|
@@ -609,7 +627,7 @@ is radians of `atan(|∇h|)`. Default textures stream from the live agent8 CDN
|
|
|
609
627
|
| `theme` | `"island"` | see table — `custom` requires `layers` |
|
|
610
628
|
| `roughness` | `0.5` | detail-octave persistence (higher = more rugged) |
|
|
611
629
|
| `detail` | `4` | detail octave count |
|
|
612
|
-
| `flatThreshold` | `0.95` | snap-flatten heights within ±0.6 m of `maxHeight·flatThreshold` |
|
|
630
|
+
| `flatThreshold` | `0.95` | snap-flatten heights within ±0.6 m of `maxHeight·flatThreshold` — a fraction of the SCALE, not of the peak, so the default plateau lands around 18% of the realized height (measured: maxHeight 28 → band at 26.6, peak 150). Read `heightAt` before choosing one |
|
|
613
631
|
| `islandEdge` | `null` | `null` = theme decides; force the rim wrap on/off with a boolean |
|
|
614
632
|
| `layers` | `[]` | custom splat layers (theme `custom` only) |
|
|
615
633
|
| `textureBase` | agent8 CDN | base URL: `<base>/<name>.png` + `<base>/<name>_normal.png` |
|
|
@@ -14,6 +14,7 @@ bunx incanto-feel src/game.scene.json
|
|
|
14
14
|
```
|
|
15
15
|
feel of /Game/Player
|
|
16
16
|
|
|
17
|
+
pushed 'move' [1, 0]
|
|
17
18
|
top speed 5.62 u/s
|
|
18
19
|
to full speed 383 ms
|
|
19
20
|
to a stop 133 ms
|
|
@@ -28,12 +29,58 @@ feel of /Game/Player
|
|
|
28
29
|
jump buffer 150 ms
|
|
29
30
|
```
|
|
30
31
|
|
|
32
|
+
A `✗` or `!` line above the numbers is what the ENGINE said while they were
|
|
33
|
+
being taken — a script that threw and was quarantined, a camera following a node
|
|
34
|
+
with no position. The measurements below it are still real (a behaviour is
|
|
35
|
+
quarantined, the node is not), but a page of confident numbers taken while a
|
|
36
|
+
script was dying reads as a healthy character, so read those lines first.
|
|
37
|
+
|
|
31
38
|
## Why this exists
|
|
32
39
|
|
|
40
|
+
**`top speed` is what the character SUSTAINS, not its fastest frame.** The probe
|
|
41
|
+
holds `move` for five seconds and takes the 90th percentile of the run, because
|
|
42
|
+
the maximum belongs to whatever hit the character last. Measured on the shipped
|
|
43
|
+
`platformer-2d`, whose `RUN_SPEED` is 250: it reported `top speed 300 u/s` —
|
|
44
|
+
that is `KNOCK_X`, from an enemy the probe walked into — and `to full speed
|
|
45
|
+
2367 ms`, which was the walk to the enemy, on a character that reaches its speed
|
|
46
|
+
in ONE frame. Four numbers, all about a character being attacked. When the peak
|
|
47
|
+
and the sustained speed disagree the report says so:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
top speed 250 u/s
|
|
51
|
+
to full speed 17 ms
|
|
52
|
+
peak 300 u/s ← SOMETHING ELSE moved it
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Measure feel somewhere nothing can hit you.
|
|
56
|
+
|
|
57
|
+
**A character that jumps in MID-AIR has no coyote window to measure.** The probe
|
|
58
|
+
lifts the body, waits, presses, and reads "vertical velocity went up" as a jump —
|
|
59
|
+
so a double jump answers yes at any delay, and so does any behaviour that pushes
|
|
60
|
+
the body up while `jump` is held (a glide, a jetpack, an updraft). It used to
|
|
61
|
+
print `coyote window always (no window)`, which reads as the opposite of the
|
|
62
|
+
truth, on two of the six shipped starters — one of which declares
|
|
63
|
+
`coyoteSeconds: 0.12` five lines from its glide. It says
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
coyote window not measurable — this character jumps in MID-AIR
|
|
67
|
+
jump buffer 33 ms (suspect — see above)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
and names the declared value it cannot confirm. To measure the window, probe a
|
|
71
|
+
build with the air jump off.
|
|
72
|
+
|
|
33
73
|
**`jumpVelocity: 4` is not a height.** It is an impulse, and what it produces
|
|
34
74
|
depends on gravity, mass, drag and `fallGravity`. The apex in world units and the
|
|
35
75
|
hang time in milliseconds are what you are actually choosing.
|
|
36
76
|
|
|
77
|
+
**It says what it pushed.** The `pushed` line names the action AND the direction
|
|
78
|
+
that produced every number under it. The probe used to hold `(1, 0)` and only
|
|
79
|
+
`(1, 0)`, so a game whose movement reads the OTHER axis of the same action —
|
|
80
|
+
`-v.y`, which is this engine's own documented forward, `getVector` being y-down —
|
|
81
|
+
measured nothing and printed the nothing as `top speed 0 u/s` with four blank
|
|
82
|
+
rows and exit 0. A racer that its own harness clocked at 41 m/s reported 0.
|
|
83
|
+
|
|
37
84
|
**The windows are MEASURED, not read.** `coyoteMs` comes from probing — lift the
|
|
38
85
|
character clear of its support, wait, press, see whether it launched, binary
|
|
39
86
|
search the boundary. A `coyoteSeconds: 0.12` that the controller never consults
|
|
@@ -52,6 +99,29 @@ reports **0 ms**. That was a real bug in this engine's own 3D controller until
|
|
|
52
99
|
| `coyote window` | **0 reads to players as "the controls are broken"**, not as a missing feature. |
|
|
53
100
|
| `jump buffer` | 0 throws away a press made a few frames before landing. |
|
|
54
101
|
|
|
102
|
+
## When it cannot move your player
|
|
103
|
+
|
|
104
|
+
If the default push finds no motion, the tool SEARCHES: every declared `vector2`
|
|
105
|
+
action, each pushed ±x and ±y, and it keeps whichever moved the body furthest.
|
|
106
|
+
That is a fallback, never a replacement — a scene that already answered cannot
|
|
107
|
+
have its numbers changed by it. Two real games it rescues: a throttle on `-v.y`,
|
|
108
|
+
and a game where an unrelated `aim` happened to be declared FIRST in the input
|
|
109
|
+
map (the default move action is "the first `vector2`").
|
|
110
|
+
|
|
111
|
+
When nothing moves it says so instead of printing a zero:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
pushed 'move', 'aim' every way (±x, ±y) — the player did not move
|
|
115
|
+
|
|
116
|
+
could not move /Game/Turret: no motion in 300 frames with 'move', 'aim' pushed
|
|
117
|
+
±x and ±y. Either the movement is not wired to a vector action, or it is
|
|
118
|
+
driven by buttons. Nothing below was measured.
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`--move <action>` pins the action explicitly, and pinning it turns the search
|
|
122
|
+
OFF — you asked about that action, so a silent answer about a different one
|
|
123
|
+
would be worse than no answer.
|
|
124
|
+
|
|
55
125
|
## It reports, it does not grade
|
|
56
126
|
|
|
57
127
|
There are no PASS/FAIL bands here on purpose. A twitch platformer and a survival
|
|
@@ -71,12 +71,13 @@ warn: World/Enemy: Chase.target — '%Playerr' matches no node in this scene.
|
|
|
71
71
|
|
|
72
72
|
— which is the one failure that used to be completely silent (a prop path
|
|
73
73
|
resolves with `getNodeOrNull`, so the scene opens and the enemy just never
|
|
74
|
-
chases).
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
chases). It works for a behaviour of YOUR OWN too, given the file that registers it:
|
|
75
|
+
`incanto-check src --behaviors src/behaviors.ts` prints the identical sentence
|
|
76
|
+
for `Archer.arrowTemplate`. Without the flag the checker has no schema for your
|
|
77
|
+
behaviours and their node-path props are invisible to it — which is why every
|
|
78
|
+
scaffolded project's `check` script passes it, and why a hand-written one that
|
|
79
|
+
does not loses the check silently. `auditScene` from `incanto/test` is the same
|
|
80
|
+
audit from inside your harness, once your behaviours are registered.
|
|
80
81
|
|
|
81
82
|
`Chase.target` and `FollowCamera.target` are `required`: an EMPTY one
|
|
82
83
|
is a load error naming the node, not a surprise in the browser.
|
|
@@ -106,6 +107,7 @@ Hit points with regen and post-hit invulnerability (i-frames). The universal
|
|
|
106
107
|
| `regenPerSec` | `0` | HP regained per second (0 = off) |
|
|
107
108
|
| `invulnerableFor` | `0` | seconds of immunity after a hit (i-frames; 0 = off) |
|
|
108
109
|
| `freeOnDeath` | `false` | `queueFree()` this node when it dies (clone-safe) |
|
|
110
|
+
| `freeParent` | `false` | with `freeOnDeath`, free the PARENT — the enemy, when `Health` rides a child node |
|
|
109
111
|
|
|
110
112
|
Signals: `damaged(amount, current)` · `healed(amount, current)` ·
|
|
111
113
|
`healthChanged(current, max)` · `died` · `revived(current)`
|
|
@@ -150,6 +152,13 @@ still while the character heals. Use `damaged`/`healed` for reacting to the HIT
|
|
|
150
152
|
> node-local, so it clones perfectly and frees the whole enemy with no wiring.
|
|
151
153
|
> (Connections are still the right tool for NON-cloned nodes, e.g. the player's
|
|
152
154
|
> `died → ScoreKeeper.loseLife`.)
|
|
155
|
+
>
|
|
156
|
+
> A node carries ONE script, so if the root is already taken — a `Patrol` you
|
|
157
|
+
> did not give `moveParent`, an `Area2D` with a `Clickable` — put `Health` on a
|
|
158
|
+
> child and add **`freeParent: true`**. Without it the child frees ITSELF and
|
|
159
|
+
> the body walks on with no health at all: an immortal enemy that takes damage
|
|
160
|
+
> from nothing and reports nothing. Same prop, same reason, as `Lifetime` and
|
|
161
|
+
> `DamageOnContact`.
|
|
153
162
|
|
|
154
163
|
## Lifetime
|
|
155
164
|
|
|
@@ -182,7 +191,10 @@ once; reaching 0 lives emits `lost` once.
|
|
|
182
191
|
| `lives` | `0` | starting lives (0 = lives disabled) |
|
|
183
192
|
| `scoreToWin` | `0` | score that triggers `won` (0 = disabled) |
|
|
184
193
|
|
|
185
|
-
Signals: `scoreChanged(score)` · `won` · `lost` · `lifeLost(lives)`
|
|
194
|
+
Signals: `scoreChanged(score)` · `won` · `lost` · `lifeLost(lives)` ·
|
|
195
|
+
`livesChanged(lives)` — the EVENT and the COUNT: `lifeLost` fires when a life is
|
|
196
|
+
spent (flash, respawn), `livesChanged` also fires when a save is restored, so a
|
|
197
|
+
lives counter belongs on that one.
|
|
186
198
|
Methods: `addScore(n)` · `setScore(n)` · `loseLife()`
|
|
187
199
|
|
|
188
200
|
```json
|
|
@@ -384,7 +396,7 @@ author markers). Emits `reachedPoint(index)` on arrival.
|
|
|
384
396
|
|
|
385
397
|
| Prop | Default | Meaning |
|
|
386
398
|
|---|---|---|
|
|
387
|
-
| `points` | `[]` | waypoints: position arrays or node-path strings (
|
|
399
|
+
| `points` | `[]` | waypoints: position arrays (LOCAL to the moved node) or node-path strings (that marker's WORLD position) — required |
|
|
388
400
|
| `speed` | `60` | units per second along the path |
|
|
389
401
|
| `loop` | `true` | wrap to the first point after the last (loop mode) |
|
|
390
402
|
| `mode` | `"loop"` | `'loop'` wraps · `'pingpong'` reverses at the ends |
|
|
@@ -395,6 +407,18 @@ author markers). Emits `reachedPoint(index)` on arrival.
|
|
|
395
407
|
|
|
396
408
|
Signals: `reachedPoint(index)`
|
|
397
409
|
|
|
410
|
+
**The two waypoint forms are in different frames, on purpose.** An array is a
|
|
411
|
+
LOCAL offset — the only thing numbers typed into a prop can mean. A node path
|
|
412
|
+
means *where that marker actually is*, so markers under `/root/Path` and
|
|
413
|
+
walkers under a spawn container work, which is how a lane is organised. Before
|
|
414
|
+
0.71 a node path was read as a local offset too, so a walker whose parent was
|
|
415
|
+
not at the markers' origin walked a shifted copy of the path in silence.
|
|
416
|
+
|
|
417
|
+
Need to CHANGE the route at runtime rather than author it? That is
|
|
418
|
+
`PathFollow` and its `setPath()` (see *Pathfinding*, below) — `Patrol.points` is read live
|
|
419
|
+
but the index and direction are not re-derived, so writing points mid-route
|
|
420
|
+
moves the corners under a walker that is still heading for the old one.
|
|
421
|
+
|
|
398
422
|
```json
|
|
399
423
|
{ "name": "Guard", "type": "Node2D",
|
|
400
424
|
"script": { "name": "Patrol", "props": { "points": [[100, 0], [300, 0]], "speed": 80, "mode": "pingpong" } } }
|
|
@@ -576,6 +600,13 @@ placeTower(pad);
|
|
|
576
600
|
"you cannot afford that" is one wire to a banner. It saves through `serialize()`
|
|
577
601
|
like `Health` and `ScoreKeeper`.
|
|
578
602
|
|
|
603
|
+
A NON-POSITIVE amount is ignored, the way `Health.damage`/`heal` have always
|
|
604
|
+
ignored one — and a negative is reported, because it is a sign flip in the
|
|
605
|
+
caller rather than an offer. `spend(-5)` used to PAY you five (any negative
|
|
606
|
+
passes the affordability test, and the subtraction then added) and `earn(-5)`
|
|
607
|
+
to take five, going round `canAfford` and `refused` entirely. `spend(0)` returns
|
|
608
|
+
`true`: you can always afford nothing.
|
|
609
|
+
|
|
579
610
|
## Wander
|
|
580
611
|
|
|
581
612
|
Seeded random roaming inside a circle around the spawn point — idle critters,
|
|
@@ -665,6 +696,15 @@ are NOT cloned):
|
|
|
665
696
|
- **(B) scene `connection`** (fine for a single authored entity, NOT for clones):
|
|
666
697
|
`{ "signal": "movementStateChanged", "from": "Enemy/AI", "to": "Enemy/Skin", "handler": "setClip" }`.
|
|
667
698
|
|
|
699
|
+
**Subscribing in `onReady` is safe to do to anything, including a node that
|
|
700
|
+
outlives you.** A connection made there is owned by the node making it, so
|
|
701
|
+
`free()` takes it with the node — you do not have to keep the returned
|
|
702
|
+
disconnect and call it yourself. That matters most for the shape this pattern
|
|
703
|
+
invites: every enemy subscribing to the score keeper or the player, where the
|
|
704
|
+
emitter outlives thousands of listeners. (Wiring a signal from a `update()` or
|
|
705
|
+
from outside a lifecycle method still hands ownership to you — keep the
|
|
706
|
+
disconnect, or pass `{ owner: someNode }`.)
|
|
707
|
+
|
|
668
708
|
Same `ZombieSkin` is the place to also FACE the heading and GROUND the body each frame
|
|
669
709
|
(see incanto-3d-character.md "+Z-FORWARD rule" and incanto-3d-models.md "Grounding").
|
|
670
710
|
|
|
@@ -722,7 +762,7 @@ all a raft, a buoy, a crate or a body needs to bob, settle and ride the swell.
|
|
|
722
762
|
|
|
723
763
|
| Prop | Default | Meaning |
|
|
724
764
|
|---|---|---|
|
|
725
|
-
| `water` | `""` | Water3D node path; empty = the first Water3D in the tree (a wrong path fails hard) |
|
|
765
|
+
| `water` | `""` | Water3D node path; empty = the first Water3D in the tree (a wrong path fails hard; NO water in the scene is an `incanto-check` warning) |
|
|
726
766
|
| `draft` | `0.35` | where the resting WATERLINE sits below the body origin, in meters — the hull floats with its origin that far above the water |
|
|
727
767
|
| `stiffness` | `3` | how stiffly it returns to that waterline (extra g of lift per draft of submersion): 1 wallows, 3 is a firm dinghy, 8 is a cork |
|
|
728
768
|
| `damping` | `3.5` | vertical damping (1/s) — how fast the bobbing settles |
|
|
@@ -782,7 +822,7 @@ later clones get `EnemyTemplate2`, `EnemyTemplate3`, …)
|
|
|
782
822
|
| Prop | Default | Meaning |
|
|
783
823
|
|---|---|---|
|
|
784
824
|
| `prefab` | `""` | node path of the template to clone (required) |
|
|
785
|
-
| `interval` | `1` | seconds between spawns |
|
|
825
|
+
| `interval` | `1` | seconds between spawns — `0` is one clone per FRAME and is refused unless `max` or `total` caps it |
|
|
786
826
|
| `max` | `0` | max LIVE instances (0 = unlimited) |
|
|
787
827
|
| `at` | `[]` | where the clone appears, as an offset from the spawner ([x,y(,z)]) |
|
|
788
828
|
| `autoStart` | `true` | begin ticking at ready |
|
|
@@ -862,19 +902,55 @@ union-typed prop so its default is `null` (= `'forward'`).
|
|
|
862
902
|
|
|
863
903
|
In 3D, `'forward'` is the engine's ONE facing convention — **+Z**, the same
|
|
864
904
|
`atan2(dx, dz)` basis `CharacterController3D` uses and `incanto-3d-character.md`
|
|
865
|
-
spells out under "the +Z-FORWARD rule". So aim the
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
905
|
+
spells out under "the +Z-FORWARD rule". So aim the BULLET with that formula and
|
|
906
|
+
it flies at what you aimed at; do not add 180°. (Before 0.62 this returned
|
|
907
|
+
three.js's −Z instead, so every `'forward'` shot left the muzzle pointing at the
|
|
908
|
+
shooter's back — at the right speed, with no error, which reads as a gun that
|
|
909
|
+
simply never hits anything.) In 2D `rotation` is a scalar and `'forward'` is +x
|
|
910
|
+
turned clockwise by it, unchanged.
|
|
911
|
+
|
|
912
|
+
**Aim the bullet, not the shooter.** Turning a turret does not turn a bullet
|
|
913
|
+
parented under it: world position is composed TRANSLATION-ONLY, so a bolt under
|
|
914
|
+
a turret at `rotation: 90` still lands at world `[100, 0]`, not `[0, 100]`. Set
|
|
915
|
+
the heading on the projectile itself.
|
|
871
916
|
|
|
872
917
|
| Prop | Default | Meaning |
|
|
873
918
|
|---|---|---|
|
|
874
|
-
| `speed` | `300` | units per second along `direction` |
|
|
875
|
-
| `direction` | `null` | a vector `[x,y(,z)]` OR `'forward'` (`null` = forward) |
|
|
919
|
+
| `speed` | `300` | units per second along `direction` — **live**, rescales in flight |
|
|
920
|
+
| `direction` | `null` | a vector `[x,y(,z)]` OR `'forward'` (`null` = forward) — **live** |
|
|
876
921
|
| `gravity` | `0` | constant +y (downward, 2D y-down) pull for arcing shots |
|
|
877
922
|
|
|
923
|
+
### Aiming a bullet you just spawned
|
|
924
|
+
|
|
925
|
+
Every prop above is LIVE, and the heading is resolved on the projectile's FIRST
|
|
926
|
+
STEP — which is after `spawned(node)` fires. That window is the whole point:
|
|
927
|
+
`SpawnSource.spawn` ends with `addChild(clone)` and `Spawner` emits `spawned`
|
|
928
|
+
afterwards, so a handler is by definition "too late" for anything baked at
|
|
929
|
+
`onReady`.
|
|
930
|
+
|
|
931
|
+
```ts
|
|
932
|
+
spawner.on('spawned', (bolt) => {
|
|
933
|
+
// either spelling works — set the node's rotation…
|
|
934
|
+
(bolt as { rotation: number }).rotation = (Math.atan2(dy, dx) * 180) / Math.PI;
|
|
935
|
+
// …or hand the behavior a vector
|
|
936
|
+
(bolt.behavior as Projectile).direction = [dx / len, dy / len];
|
|
937
|
+
});
|
|
938
|
+
```
|
|
939
|
+
|
|
940
|
+
Mid-flight, writing `direction` or `speed` re-bakes immediately (the fall
|
|
941
|
+
`gravity` has accumulated is kept — it is a fact about the world, not about the
|
|
942
|
+
shot). What is deliberately NOT live is `rotation` after that first step: a
|
|
943
|
+
projectile that spins for looks must not have its spin become its trajectory.
|
|
944
|
+
Call **`aim()`** to re-derive from the current rotation on purpose:
|
|
945
|
+
|
|
946
|
+
```ts
|
|
947
|
+
bolt.rotation = newHeadingDeg;
|
|
948
|
+
(bolt.behavior as Projectile).aim(); // or aim([dx, dy]) to pass a vector
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
Before 0.70 all of this was dead: `direction` accepted the write, READ BACK the
|
|
952
|
+
new value, and the bolt kept flying the old way.
|
|
953
|
+
|
|
878
954
|
```json
|
|
879
955
|
{ "name": "Bullet", "type": "Area2D", "props": { "rotation": 0 },
|
|
880
956
|
"script": { "name": "Projectile", "props": { "speed": 600, "direction": "forward" } } }
|
|
@@ -1175,6 +1251,14 @@ The panel is hidden while playing and shown while paused — `GameFlow` owns its
|
|
|
1175
1251
|
`visible`, so do not set it yourself. `pauseAction` and `pausePanelPath` rename
|
|
1176
1252
|
either half; `pausePanelPath: ""` turns it off.
|
|
1177
1253
|
|
|
1254
|
+
While the panel is up its `HudLayer` gets `focusNavigation` — arrow keys, d-pad
|
|
1255
|
+
and A — and the ring starts on the first widget. The layer's own value is put
|
|
1256
|
+
back on resume, so a game that navigates by pad all the time keeps doing so —
|
|
1257
|
+
unless the game CHANGED it during the pause, in which case the game had the last
|
|
1258
|
+
word and keeps it.
|
|
1259
|
+
That is the one thing every pause menu needs and nobody remembers: a menu you
|
|
1260
|
+
can only click is not playable on a controller.
|
|
1261
|
+
|
|
1178
1262
|
The pause key is polled in `update()`, which still runs at `timeScale 0` — a
|
|
1179
1263
|
menu that cannot be closed by the key that opened it is worse than no menu.
|
|
1180
1264
|
|
|
@@ -1188,7 +1272,7 @@ physics, input. Listen to the `flowChanged(state)` signal for custom UI.
|
|
|
1188
1272
|
`restartScene(engine)` is exported standalone.
|
|
1189
1273
|
|
|
1190
1274
|
**Any scene swap thaws.** The freeze lives on the engine, not on the flow, so
|
|
1191
|
-
leaving a game-over screen by your own route — `engine.setScene(loadScene(next))`
|
|
1275
|
+
leaving a game-over screen by your own route — `engine.setScene(loadScene(next, { engine }))`
|
|
1192
1276
|
from a menu button — puts `timeScale` back to 1 as surely as `flow.restart()`
|
|
1193
1277
|
does. You cannot restart into a frozen level.
|
|
1194
1278
|
|
|
@@ -1211,6 +1295,12 @@ scene with no bodies still pays for nothing.
|
|
|
1211
1295
|
Drives the scene `environment` (needs an atmosphere sky): sun elevation/
|
|
1212
1296
|
azimuth arc, ambient + exposure ramps with a moonlight floor.
|
|
1213
1297
|
|
|
1298
|
+
**No `sky` in the scene environment = nothing to drive.** The clock still runs
|
|
1299
|
+
and `dayPhaseChanged` still fires, so the signals look right and the screen
|
|
1300
|
+
never changes; the behaviour says so once, in the engine log. Add
|
|
1301
|
+
`"sky": { "type": "atmosphere" }` to the scene's `environment` — or set it at
|
|
1302
|
+
runtime, which it keeps looking for.
|
|
1303
|
+
|
|
1214
1304
|
```jsonc
|
|
1215
1305
|
{ "script": { "name": "DayNight", "props": { "daySeconds": 240, "startHour": 9 } } }
|
|
1216
1306
|
```
|
package/skills/incanto-hud.md
CHANGED
|
@@ -25,6 +25,11 @@ Declare your HUD in the scene JSON — no `index.html` markup, no CSS, no
|
|
|
25
25
|
works identically over the 2D and 3D renderers and is a silent no-op in
|
|
26
26
|
headless tests (core nodes, no three.js). Widgets pick one of 9 anchors:
|
|
27
27
|
`topLeft top topRight left center right bottomLeft bottom bottomRight`.
|
|
28
|
+
|
|
29
|
+
**Camel case here, hyphens in `UILayer`.** The 2D world-space layer spells the
|
|
30
|
+
same nine `top-left`/`bottom-right`, and neither prop accepts the other's
|
|
31
|
+
spelling — both fail at load listing their own set, so you are one edit from
|
|
32
|
+
right. Worth knowing before you spend the edit.
|
|
28
33
|
Widgets stacked on the same anchor form a column.
|
|
29
34
|
|
|
30
35
|
## Driving widgets from the scene JSON (no TypeScript)
|
|
@@ -36,10 +41,15 @@ are `connections[]` entries — not a behavior whose whole job is one assignment
|
|
|
36
41
|
"connections": [
|
|
37
42
|
{ "signal": "scoreChanged", "from": ".", "to": "HUD/Score", "handler": "setText" },
|
|
38
43
|
{ "signal": "healthChanged", "from": "Player", "to": "HUD/Hp", "handler": "setValue" },
|
|
39
|
-
{ "signal": "
|
|
44
|
+
{ "signal": "livesChanged", "from": ".", "to": "HUD/Lives", "handler": "setText" }
|
|
40
45
|
]
|
|
41
46
|
```
|
|
42
47
|
|
|
48
|
+
**`livesChanged`, not `lifeLost`, for the counter.** `lifeLost` is the EVENT — a
|
|
49
|
+
life was just spent, flash the screen, respawn — and it does not fire when a
|
|
50
|
+
SAVE is loaded, so a counter wired to it still read `3` after a Continue at one
|
|
51
|
+
life left. `livesChanged` is the COUNT, and fires on both.
|
|
52
|
+
|
|
43
53
|
```json
|
|
44
54
|
{ "name": "Score", "type": "UiText",
|
|
45
55
|
"props": { "anchor": "topRight", "text": "Gems 0 / 8", "format": "Gems {} / 8" } }
|
|
@@ -93,9 +103,58 @@ banner.show('YOU DIED', { color: '#ef4444', seconds: 0 }); // sticky until next
|
|
|
93
103
|
the queue; signal `bannerShown(text)`. Props: `size` (font px), `seconds`
|
|
94
104
|
(default duration).
|
|
95
105
|
|
|
106
|
+
**Showing and hiding a widget is `visible`, not a method.** There is no
|
|
107
|
+
`hide()`/`show()` pair on a widget: `UiBanner.show(text)` announces a LINE, and
|
|
108
|
+
every widget's own visibility is the ordinary `visible` prop it inherits from
|
|
109
|
+
every other node —
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
(this.node.getNode('%Pause') as UiPanel).visible = false; // a whole menu, and
|
|
113
|
+
// everything under it
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
A panel hides its children with it, so one write takes a whole screen away.
|
|
117
|
+
(HUD widgets are screen-space, so `framing()` leaves them out entirely — asking
|
|
118
|
+
whether the camera can see one is a category error.)
|
|
119
|
+
|
|
96
120
|
Pair with the `Health` / `ScoreKeeper` gameplay behaviors: listen to their
|
|
97
121
|
signals and write the widget props — that is the whole HUD wiring.
|
|
98
122
|
|
|
123
|
+
## On a phone
|
|
124
|
+
|
|
125
|
+
The nine anchors keep out of the device's own furniture: each is 16 px from its
|
|
126
|
+
edge **plus** that edge's `env(safe-area-inset-*)`. Every scaffolded
|
|
127
|
+
`index.html` carries `viewport-fit=cover` — which is what makes a game fill a
|
|
128
|
+
phone edge to edge, and what would otherwise put `anchor: "bottom"` under the
|
|
129
|
+
home indicator, where iOS takes the gesture and your button never hears the tap.
|
|
130
|
+
`topRight` behind the notch and `left`/`right` under the rounded corners are the
|
|
131
|
+
same story in landscape, which is how a phone is held for a game.
|
|
132
|
+
|
|
133
|
+
The insets are ADDED, and every desktop browser reports 0 for all four, so
|
|
134
|
+
nothing moves where there is nothing to avoid. (The touch-control overlay has
|
|
135
|
+
done this since 0.42; the HUD, which is the overlay with the buttons you
|
|
136
|
+
actually tap, joined it much later.)
|
|
137
|
+
|
|
138
|
+
**A widget authored in pixels still fits the screen.** `UiPanel`, `UiBar`,
|
|
139
|
+
`UiImage`, `UiSlider` and `UiDialogue` all cap at `calc(100vw - 32px)` — a pause
|
|
140
|
+
panel at `width: 520` on a 390 px phone would otherwise hang 130 px off the
|
|
141
|
+
edge, taking its buttons with it, and a panel too TALL scrolls rather than
|
|
142
|
+
hiding the row that says Resume.
|
|
143
|
+
|
|
144
|
+
**Every tappable widget is at least 44x44.** Measured in Chrome, a `UiButton`
|
|
145
|
+
used to come out 131x37 and a dialogue choice ~50x29, while the engine's own
|
|
146
|
+
touch buttons have been 64x64 and its stick 120x120 for years — the surface a
|
|
147
|
+
finger actually lands on was the one nobody had sized for a finger. Apple asks
|
|
148
|
+
44, Material 48, WCAG 2.5.5 44. It is a MINIMUM: a button with more text stays
|
|
149
|
+
as wide as its text, and an authored `width` still wins.
|
|
150
|
+
|
|
151
|
+
The layer also takes the GESTURES over itself: every widget that receives taps
|
|
152
|
+
sets `touch-action: none`, and the layer turns off text selection, the iOS
|
|
153
|
+
long-press callout and the tap flash. `claimCanvasGestures` has done that for
|
|
154
|
+
the canvas for a while — but the HUD is a separate overlay ABOVE it, and a
|
|
155
|
+
swipe that starts on the score at the top of the screen never reaches the
|
|
156
|
+
canvas at all. It used to scroll the page or pull-to-refresh.
|
|
157
|
+
|
|
99
158
|
## Interactive widgets: UiButton & UiDialogue
|
|
100
159
|
|
|
101
160
|
```json
|
|
@@ -120,6 +179,18 @@ reveals the line then advances; choice lines render buttons and wait for
|
|
|
120
179
|
`choose(i)`. Buttons opt into pointer events — the rest of the HUD stays
|
|
121
180
|
click-through.
|
|
122
181
|
|
|
182
|
+
**Driving them with no screen** — a HUD widget is DOM, so a headless harness
|
|
183
|
+
cannot click one. Both take the gesture directly:
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
(hud.getNode('Start') as UiButton).press(); // emits `pressed`, as a click would
|
|
187
|
+
(hud.getNode('Talk') as UiDialogue).advance(); // reveal the rest, then next line
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
That is how a title screen, a pause menu or a conversation gets tested in
|
|
191
|
+
`runScript` — `click` reaches world nodes through the picker, and a widget is
|
|
192
|
+
not one of those.
|
|
193
|
+
|
|
123
194
|
## Menus, options and inventories (UiPanel + the value widgets)
|
|
124
195
|
|
|
125
196
|
The HUD widgets can SAY things. These arrange them and take a value back — which
|
|
@@ -151,13 +222,34 @@ so structure in the tree becomes structure on screen. Panels nest.
|
|
|
151
222
|
| `UiSlider` | `label`, `value`, `min`, `max`, `step`, `width`, `color` | `changed(value)` |
|
|
152
223
|
| `UiToggle` | `label`, `value` | `changed(bool)` |
|
|
153
224
|
| `UiSelect` | `label`, `options` (`"low,medium,high"`), `value` | `changed(value)` |
|
|
154
|
-
| `UiVolumeSlider` | `bus` (`master`/`sfx`/`music`), plus every `UiSlider` prop | `changed(value)` |
|
|
155
|
-
| `UiMuteToggle` | `label` | `changed(bool)` |
|
|
156
225
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
226
|
+
`UiSelect.value` must be one of its `options` — a value the list cannot show is
|
|
227
|
+
a hard load error naming them, because the browser would show the FIRST option
|
|
228
|
+
while the node went on answering with the value it was given, and `changed`
|
|
229
|
+
only fires when a person moves it. (Writing one at runtime is reported rather
|
|
230
|
+
than refused: a behaviour may widen `options` a frame later, and it goes quiet
|
|
231
|
+
when it does.) `""` is "nothing chosen yet", which is a choice.
|
|
232
|
+
### The ones that need no TypeScript at all
|
|
233
|
+
|
|
234
|
+
| node | props | follows |
|
|
235
|
+
| --- | --- | --- |
|
|
236
|
+
| `UiVolumeSlider` | `bus` (`master`/`sfx`/`music`), plus every `UiSlider` prop | `engine.audio[bus]` |
|
|
237
|
+
| `UiMuteToggle` | `label` | `engine.audio.muted` |
|
|
238
|
+
| `UiQualitySelect` | — | `engine.settings` `quality` |
|
|
239
|
+
| `UiFrameCapSelect` | — | `engine.settings` `maxFps` |
|
|
240
|
+
| `UiRenderScaleSelect` | — | `engine.settings` `renderScale` |
|
|
241
|
+
| `UiLanguageSelect` | — | `engine.locale` (options are the scene's own locales) |
|
|
242
|
+
|
|
243
|
+
These are **already wired** in both directions: they show what the game is set
|
|
244
|
+
to, and setting one changes the game. A whole settings screen is those six nodes
|
|
245
|
+
and no TypeScript.
|
|
246
|
+
|
|
247
|
+
**They follow the engine HEADLESS too**, so a harness can drive one: set
|
|
248
|
+
`slider.value`, step, and assert `engine.audio.master` moved. These used to live
|
|
249
|
+
on the painting side of the widget, below `update`'s early
|
|
250
|
+
return for "no DOM element" — so every one of them was inert in `runScript`,
|
|
251
|
+
`incanto-playtest` and `incanto-verify`, showing a `UiSlider`'s 0.5 default next
|
|
252
|
+
to a master volume of 1.
|
|
161
253
|
|
|
162
254
|
**An inventory is a grid panel**: `"layout": "grid", "columns": 5`, one child per
|
|
163
255
|
slot, each a small `UiPanel` holding a `UiImage` (`tint` greys out what you
|
|
@@ -204,12 +296,25 @@ What activation MEANS is per widget: a button presses, a toggle flips (left/righ
|
|
|
204
296
|
sets it explicitly, which reads better on a pad), a select walks its list, a
|
|
205
297
|
slider nudges by one `step`.
|
|
206
298
|
|
|
299
|
+
**A `GameFlow` pause panel arms it for you** — that screen IS a menu, it knows
|
|
300
|
+
exactly when it opens and closes, and it puts the layer's own value back on
|
|
301
|
+
resume. Every game with a pause menu was otherwise writing the same two lines,
|
|
302
|
+
or shipping a menu that answered only to a mouse.
|
|
303
|
+
|
|
207
304
|
**It is OFF by default**, deliberately: a game whose HUD happens to contain a
|
|
208
305
|
button must not lose its arrow keys the moment one exists. Turn it on for the
|
|
209
306
|
screens that ARE menus and off again when play resumes —
|
|
210
307
|
`hud.focusNavigation = false`. `hud.focus(widget)` sets the starting item, since
|
|
211
308
|
opening a menu should land somewhere rather than nowhere.
|
|
212
309
|
|
|
310
|
+
**With two layers, the TOPMOST armed one takes the key** — last in the tree,
|
|
311
|
+
which is the one drawn on top, and the one a modal is. Keyboard focus is
|
|
312
|
+
singular by nature (a browser has one focused element); when both a HUD and a
|
|
313
|
+
modal were armed, a single Enter activated the focused widget in EACH, so the
|
|
314
|
+
pause menu's RESUME and whatever the screen underneath had focused both fired.
|
|
315
|
+
A HIDDEN layer is not armed at all, so a closed menu never eats the key from the
|
|
316
|
+
HUD it covers.
|
|
317
|
+
|
|
213
318
|
The gamepad codes are the ones the engine already produces from a pad
|
|
214
319
|
(`Pad12`–`Pad15` d-pad, `Pad0` = A), so nothing extra is declared.
|
|
215
320
|
|
|
@@ -244,6 +349,22 @@ A drop on nothing cancels, and so does putting a thing back into the slot it
|
|
|
244
349
|
came from: that is not a move, and firing `dropped` for it would make every
|
|
245
350
|
mis-grab look like a transfer.
|
|
246
351
|
|
|
352
|
+
**A harness can make the gesture.** This is the one screen the paragraph above
|
|
353
|
+
says a click cannot express, and for a long time it was also the one screen no
|
|
354
|
+
headless check could reach at all — every one of the four signals lived on a
|
|
355
|
+
DOM listener, so `runScript`, `incanto-playtest` and every rung of the ladder
|
|
356
|
+
were blind to an inventory.
|
|
357
|
+
|
|
358
|
+
```ts
|
|
359
|
+
{ atMs: 200, do: (ctx) => (ctx.getNode('%Potion') as UiImage)
|
|
360
|
+
.dropOnto(ctx.getNode('%SlotB') as UiPanel) }
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
`dropOnto(target)` is to a drag what `press()` is to a click: the same rules as
|
|
364
|
+
the pointer path — a non-`draggable` source does nothing, a target that is not a
|
|
365
|
+
`dropTarget` cancels, and putting a thing back where it came from is not a move
|
|
366
|
+
— and it returns whether the drop was taken.
|
|
367
|
+
|
|
247
368
|
|
|
248
369
|
|
|
249
370
|
## More than one language
|