# Firefly
The body each player gets: a glowing firefly that flies to wherever its owner last touched or clicked the play field, so everyone sees where their friends are playing. Put it on the PlayerPrototype's body entity; only the owning peer moves it and the engine replicates the pose.
# StarfallGame
The whole game on one synced entity (`StarfallGame` in the main scene). Its synced fields are the round's shared state, written by the authority: `wilted` (garden flowers lost), `moon` (the shared Moonburst meter, 0..1), plus settings `roundSeconds`, `gardenLives` and `look` (the touch kits' overall style). Every peer runs `starfallGarden.game` from it.
# TouchShowcase
The "Touch styles" room of Starfall Garden: see and try every touch style side by side. Page **Feedback styles** is fingertipKit's gallery (every tap ripple, finger trail, button press effect and gesture hint, with buttons to switch between the five looks); page **Tap targets** is touchTargetsKit's gallery (3D objects to tap for each hit reaction and hold for each hold ring, in the same five looks). A bar at the bottom flips the page and goes back to the game. It draws on the visitor's own screen only. It lives in `scenes.touchShowcase`, which the game loads as an overlay on the running garden (`Round.openShowcase()`); Back calls `Round.closeShowcase()` and the game takes the overlay down. Fields: `page` (`feedback` or `targets`) and `look`. Needs no sibling components.
# art
Starfall Garden's look, built in code (the model generator was out of quota): a pillowy smiling star, a thorny gloom wisp with glowing eyes, a pearly seed pod in mint leaves, garden flowers that wilt, and the player's firefly. `Art.star(e)`, `Art.gloom(e)`, `Art.pod(e)`, `Art.flower(e, variant, size)`, `Art.setWilted(flower, bool)`, `Art.firefly(e)`. Meshes are generated once per peer with `renderer.mesh.create` and cached; pieces are temporary local children, so synced objects carry only gameplay data. Materials live in `materials/`.
# bloom
A soft magical blooming sound, a rising harp glissando with sparkles. Starfall Garden plays it when a seed pod you held bursts into bloom.
# catch
A bright, short twinkling bell chime. Starfall Garden plays it when you tap a falling star and catch it, and on GO.
# countdown
A single soft wooden tick blip. Starfall Garden plays it on each 3-2-1 of the round countdown.
# hurt
A soft, sad low thump with a wilting, descending wobble. Starfall Garden plays it when a gloom wisp lands in the garden and wilts a flower.
# lose
A short, gentle, sad game-over jingle on descending music-box notes. Starfall Garden plays it when the garden wilts and the round is lost.
# moonburst
A big magical whoosh burst with shimmering chimes. Starfall Garden plays it when a player double-taps a full moon meter and the Moonburst clears every gloom wisp.
# music
A dreamy, upbeat lullaby loop: music-box melody, soft synth pads, plucked harp and gentle shaker at about 100 bpm. Starfall Garden's background music, looping all session.
# slice
A quick airy swoosh with a soft puff. Starfall Garden plays it when you swipe through a gloom wisp and slice it.
# win
A short, happy victory fanfare on music box and bells. Starfall Garden plays it when the garden survives the 90-second round.
# game
What the `StarfallGame` component runs on every peer: builds the garden flowers (the garden's lives) and sways or wilts them from the synced `wilted` count, keeps the fixed camera framing the whole play field on landscape and portrait screens, and starts the round (`starfallGarden.round`) when the scene plays.
# hud
The in-round HUD that is Starfall Garden's own: the garden's five flowers (lives) and the shared Moonburst meter, top centre, with a pulsing DOUBLE-TAP prompt when the meter is full. `Hud.update({ visible, lives, wilted, moon })` every frame re-registers only on change; it takes no pointer, so touches pass through to the game.
# progress
Player progression saved per player with `runtime_data`: lifetime stars caught, best score, rounds played, a gardener rank (Seedling, Sprout, Bud, Bloom, Starcatcher, Moon Gardener) and the fingertipKit finger-trail style each rank unlocks. `Progress.record()`, `Progress.finishRound(stars, score)`, `Progress.chooseTrail(name)`.
# round
The round of Starfall Garden, assembled from the installed kits: skyfallKit drops stars, gloom wisps and seed pods in waves; touchTargetsKit turns a tap, a swipe or a hold on them into a catch; scoreKit scores and combos; MatchFlow runs one shared 90-second round with a 3-2-1-GO; menusKit shows the title, victory and game-over screens with Play again; juiceKit shakes and sparkles; fingertipKit draws every finger and teaches each gesture on the first play. It keeps only the game's own rules: points per kind, the shared moon meter and Moonburst (double tap), gloom that lands wilting a flower, pods that revive one.
# sounds
Starfall Garden's audio, generated with the engine's audio generation: a dreamy music-box loop and one-shots for catch, slice, bloom, hurt, moonburst, win, lose and the countdown. `Sounds.play(name)` and `Sounds.music(on)`, played locally on each peer through one non-spatial Audio host.
# stage
Starfall Garden's layout numbers in one place: the sky preset, the garden island, the distant islets, the vertical play field things fall through, the fixed camera and the five garden flowers. The scene build (`scenes/main.scene/build.luau`) and the game modules both read it so they always agree.
# touchTargetsKit
**Make 3D objects tappable, double-tappable, holdable, swipeable (slice through them) and draggable on touch screens, with forgiving fingertip-sized hit circles, hit reactions, hold-progress rings and highlights, and one winner per target in multiplayer.**
Version **1.0.1** (`TT.VERSION`). The version, this README and `package.yaml` move together.
## Install
1. Search ZeroMind for **touchTargetsKit** and install `touchTargetsKit.package`, or install it by its guid once published (`zeromind_install guid=<touchTargetsKit guid>`). It depends on **juiceKit** (hit particles), which the install brings along.
2. `local TT = require("touchTargetsKit.targets")` from any component or module that runs in play.
3. `TT.start()` once, then `TT.add(entity, { gestures = "tap" })` for each object.
Or with no code: put the **TouchTarget** component on an entity and set its fields.
## Quick start
```lua
local TT = require("touchTargetsKit.targets")
TT.start({ look = "neon" }) -- once per client; safe to call again
-- a small star you tap
TT.add(star, { gestures = "tap", radius = 0.3, kind = "star", points = 10, reaction = "sparkle" })
-- a wisp you slice by swiping through it
TT.add(wisp, { gestures = "swipe", radius = 0.5, kind = "wisp", points = 25, reaction = "shatter" })
-- a seed pod you hold for a second
TT.add(pod, { gestures = "hold", holdSeconds = 1.0, radius = 0.6, kind = "pod", holdRing = "petals", reaction = "pop" })
-- a crate you drag, which stays (consume = false)
TT.add(crate, { gestures = "drag", radius = 0.5, consume = false })
TT.onHit(function(ev) -- every peer, once per hit
if ev.isLocal then score += ev.points end
end)
TT.onMiss(function(ev) -- this client only
if ev.reason == "wrongGesture" then showHint(ev.entity, ev.gesture) end
end)
TT.onDrag(function(ev) -- this client only
if ev.phase == "move" then crate.position = { ev.position.x, ev.position.y, ev.position.z } end
end)
```
`require("touchTargetsKit.gallery").spawn()` in play spawns a row of every reaction (tap them) and every hold ring (hold them) in front of the camera.
## How touches are recognised
- Each client recognises its own fingers against every target's **screen position** (`worldToScreen`, scene viewport physical pixels, the space of `Zin.touch.slots()`). The mouse is one more finger while no touch is down.
- A target's hit circle is its projected radius times 1.15, but **never smaller than `minRadius` logical points** (default 44, times `ui.pixelRatio()`), so a tiny, far or fast object is still easy to hit. Overlapping circles go to the one the finger is most central in.
- **tap**: lift within the slop (22 pt). A long press on a tap target still counts (forgiving). **doubleTap**: two taps within 0.32 s; a target that takes both tap and doubleTap waits out the window before a single tap. **hold**: keep the finger on it for `holdSeconds`; the finger may wobble up to 1.4 hit radii; the hold ring shows the progress. **swipe**: a finger moving faster than 380 pt/s slices every swipe target whose circle the segment between two consecutive samples crosses, during the move, so a fast swipe never skips one. **drag**: the finger grabs it once it leaves the slop; `onDrag` reports `begin`/`move`/`end` with the finger's point on a plane (`dragPlane = "view"`, facing the camera through the object, or `"ground"`, horizontal) and `position`, where the object goes keeping the grab offset. **any**: tap, doubleTap (as a tap), hold and swipe all hit it.
- A tap on a target that needs another gesture, or a swipe that crosses only non-swipe targets, is a `miss` with `reason = "wrongGesture"` and the entity; a gesture over nothing is `reason = "empty"`.
- Each target's circle is stated as a touch region the kit holds (`input.setTouchClaims`), so a finger that lands on a target belongs to the game even inside the on-screen look area. Contacts on an on-screen button are left alone. `TT.config.claimTouches = false` turns this off.
## Styles
Every style is one setting per target (or per `TT.add` call); `look` is global.
| Setting | Values |
|---|---|
| `reaction` (on hit) | `pop`, `shatter`, `squash`, `spinAway`, `fade`, `sparkle`, `none` |
| `holdRing` (hold progress) | `ring`, `fill`, `petals`, `segments`, `dots` |
| `highlight` (finger over it) | `glow`, `outline`, `grow`, `none` |
| `look` (`TT.setLook`) | `cartoon`, `minimal`, `neon`, `pixel`, `pastel` |
Rings, highlights and shatter shards are drawn by four pooled instanced draws (no entity per indicator, at most 256 instances each, 48 targets lit at once); reactions animate the entity's transform and play a juiceKit effect in the look's matching juice look. On a mid-range tablet the kit's frame costs a few hundred table writes and four buffer uploads.
## API
```lua
TT.start(opts?) -- idempotent; opts.look, opts.minRadius (logical points, default 44), opts.enabled
TT.stop() -- stop recognising on this client; indicators clear, targets stay registered
TT.add(entity, opts) -> id
-- opts: gestures = "tap" | { "tap", "swipe", ... }, radius = 1.0 (world units), holdSeconds = 0.7,
-- kind = "target", points = 0, reaction = "pop", holdRing = "ring", highlight = "glow",
-- consume = true, data = {}, dragPlane = "view" | "ground", despawn = true,
-- positionOf = function() return {x,y,z} end -- local: where the object is drawn
-- calling add again on the same entity updates it (one target per entity);
-- a target whose entity is despawned is dropped automatically
TT.remove(entityOrId)
TT.onHit(fn, opts?) -- every peer: { entity, id, kind, gesture, player, peer, isLocal, points, data, screenX, screenY, world = {x,y,z} }
-- player = the winner's user id, peer = the winner's peer id (two devices on one account differ by peer)
-- opts.key: registering again under the same key replaces the earlier listener (also onMiss, onHoldProgress, onDrag)
TT.onMiss(fn) -- local: { gesture, screenX, screenY, reason = "empty" | "wrongGesture", entity?, id?, kind?, early? }
TT.onHoldProgress(fn) -- local: { entity, id, progress } (0 when the finger lets go early)
TT.onDrag(fn) -- local: { entity, id, phase = "begin" | "move" | "end", world, position, screenX, screenY }
TT.setLook(name) TT.getLook() TT.looks() TT.reactions() TT.holdRings() TT.highlights() TT.gestures()
TT.setEnabled(bool) TT.isEnabled() TT.isStarted()
TT.get(entityOrId) -- the target's settings and live screen circle
TT.list() TT.stats() TT.config TT.VERSION
```
Every `on*` returns a function that unsubscribes. `id` is the entity's id. `screenX/screenY` in a hit are where the winning player's finger was, on their screen. `player` is the winner's user id. Drag never produces a hit; the game moves the object (from the peer that owns it).
## Multiplayer rules
- **Claims**: the client that saw the gesture sends a claim on `multiplayer.send("touchTargetsKit.claim", ...)`. The **authority** for a target is its owner for a synced entity (`entity:owner()`, `isLocal()`), else the host (`multiplayer.isHost()`), which also covers scene entities every peer builds its own copy of.
- **One winner**: the authority accepts the first claim; a consumed target is dead from then on and later claims are refused; a target that stays (`consume = false`) refuses claims for 0.12 s after a hit. It broadcasts the hit on `touchTargetsKit.hit` with a unique hit id and applies it locally, so `onHit` fires once on every peer, the winner's included (`isLocal = true` there only).
- **Reactions** play on every peer; the transform animation runs on the peer that may write the entity (its owner, or every peer for an unsynced copy) and replicates from there. With `consume = true` that peer despawns the entity when the reaction ends (`despawn = false` hides it instead), and every other peer hides its view.
- **Registration**: `TT.add` on a synced entity this peer owns tells every other peer (`touchTargetsKit.reg`), and a client that starts later asks the owners (`touchTargetsKit.ask`), so the host can spawn synced targets and register them once. Calling `TT.add` on every peer (the TouchTarget component does) works the same.
- **A synced entity that stands still while a local child moves**: call `TT.add(syncedEntity, { positionOf = function() return bodyPos end, ... })` on every peer. Projection, highlights, hold rings, the hit's `world` and the reaction effects use the callback; claims and ids stay keyed by the synced entity, and a consumed one is despawned by its owner. A registration arriving from another peer never clears a callback this peer set.
- **Single player** needs nothing: with no relay the local client is the authority.
- Indicators, highlights, misses, hold progress and drags are local to the player whose finger it is.
## Parts
- `targets.module`: the API above, recognition, claims and drawing of indicators.
- `TouchTarget.component`: the no-code way; its fields are the `TT.add` settings.
- `gallery.module`: `spawn(opts)` / `clear()`, every reaction and hold ring side by side.
- `reactions.module`, `overlay.module`, `styles.module`, `state.module`: the reactions, the pooled instanced draws, the style tables, and the state that survives a hot reload.
- Guides: **How to make 3D objects tappable, swipeable and holdable on touch screens** (`touchTargetsKit.package/how-to-make-3d-objects-tappable-swipeable-and-holdable-on-touch-screens`) and **Example: build a tap-and-slice touch arcade game** (`touchTargetsKit.package/example-build-a-tap-and-slice-touch-arcade-game`).
## Listeners and play sessions
Listeners live in state that outlasts a hot reload and a trip out of play
and back. Each listener is stamped with the play session it was registered
in, and one left over from an earlier session is dropped the next time an
event fires, so a listener a game forgot to unsubscribe can never count a hit
twice. A game that registers its listeners again every round should pass
`{ key = "..." }` so the new one replaces the old.
## Mouse
The left mouse button is one more finger (ignored for `mouseAfterTouch`
seconds after a touch). A mouse sweeps slower than a flicking finger, so a
mouse drag slices at `TT.config.mouseSwipeSpeed` (200 points per second)
instead of `swipeSpeed` (380).
## Changelog
- **1.0.1**: hits carry `peer` (the winner's peer id); `onHit` / `onMiss` / `onHoldProgress` / `onDrag` take `{ key }` to replace an earlier listener; listeners from an earlier play session are dropped instead of firing again; a mouse drag slices at its own, gentler speed (`mouseSwipeSpeed`).
- **1.0.0**: first release.
## Known limits
- A hit arrives after the round trip to the authority (no optimistic reaction on the claimer); the target stops taking claims from that finger while it waits.
- A contact an on-screen control already holds (a button, the movement stick) is not a target finger; a swipe that starts inside the look area and never crosses a target's circle on its first frame can be taken by the look area.
- `grow` scales the entity only on a peer that may write it; elsewhere it shows as a soft halo.
# skyfallKit
Things that fall, drift, rise or fly across a play area in waves, for arcade games: falling stars to catch, fruit thrown up to slice, balloons and bubbles rising to pop, meteors to dodge, leaves to grab. Multiplayer-correct and cheap: one authority decides what spawns, and every screen computes the motion itself, so it is smooth everywhere without streaming a single transform.
Version **1.0.4** (`Skyfall.VERSION`). This README, `package.yaml` and `Skyfall.VERSION` move together.
## What you get
- **8 motions** (per object): `drop` (straight down, gently accelerating), `zigzag`, `swirl` (spirals down through the depth), `float` (wobbly leaf drift), `arc` (thrown up from below, then falls, like fruit-slicing games), `bounce` (three bounces on the floor, then through it), `rise` (bubbles, balloons), `dart` (fast diagonal streak).
- **8 wave patterns**: `rain` (random across the width), `line` (a row), `vee`, `burst` (from one point, fanning out), `spiral`, `sides` (in from the left and right edges), `lanes` (fixed columns), `fountain` (thrown up from below).
- **5 entry effects**: `popIn`, `fadeIn`, `streak`, `sparkle`, `none`; **4 warning markers** where an object will enter: `ring`, `arrow`, `glow`, `none`.
- **5 placeholder looks**: `cartoon` (bright, outlined), `minimal` (matte single shapes), `neon` (glowing), `pixel` (blocky), `pastel` (soft). Ten built-in shapes: orb, star, gem, bubble, balloon, rock, fruit, bomb, drop, leaf.
- **5 difficulty curves** over a round: `linear`, `easeIn`, `steps`, `waves` (breather moments), `flat` — spawnerKit's curves (`~spawnerKit.curves`) read over the round.
- **Events on every peer**: `spawned`, `escaped` (left the play area, e.g. hit the ground: lose a life), `removed` (caught, cleared, or despawned by something else).
- A **`SkyfallDirector` component** for a no-code shower, and a **gallery** demo showing every motion side by side.
## Install
Search ZeroMind for **skyfallKit** (or "things falling from the sky in waves") and install `skyfallKit.package`; once published, install it by its guid with `zeromind_install`. It brings spawnerKit's curves module with it. Then:
```lua
local Skyfall = require("skyfallKit.skyfall")
```
## Quick start (code)
```lua
local Skyfall = require("skyfallKit.skyfall")
-- 1. Kinds: call on EVERY peer (module scope or the world entrypoint), never only on the host.
Skyfall.defineKind("star", { shape = "star", motion = "float", speed = 2.0, radius = 0.6, data = { points = 10 } })
Skyfall.defineKind("gloom", { shape = "bomb", motion = "drop", speed = 2.4, radius = 0.6, data = { points = -20 } })
-- 2. Events: every peer hears them, late joiners included.
Skyfall.on("escaped", function(ev) if ev.kind == "star" then loseLife() end end)
Skyfall.on("removed", function(ev) if ev.reason == "caught" then addScore(ev.data.points) end end)
-- 3. When play starts: the authority creates the director (other peers get a handle to it).
local dir = Skyfall.director({
name = "Skyfall",
area = { center = {0, 6, 0}, width = 14, height = 10, depth = 2, down = {0, -1, 0} },
look = "pastel", warning = "ring", entry = "popIn", curve = "easeIn", maxAlive = 40,
})
-- 4. A 90-second round that ramps up (authority only; harmless elsewhere).
Skyfall.run({ seconds = 90, curve = "easeIn", every = 3, waves = {
{ pattern = "rain", kinds = { "star", "star", "gloom" }, count = 6, gap = 0.4 },
{ pattern = "vee", kinds = { "star" }, count = 7, gap = 0.15 },
{ pattern = "sides", kinds = { "star", "gloom" }, count = 6, gap = 0.3, motion = "float" },
} })
-- 5. Catching: from any peer (forwarded to the authority).
Skyfall.remove(entity, "caught")
```
## Quick start (no code)
Add a **SkyfallDirector** component to an empty entity in your scene and press play. With `autoRun` on (default) it runs a looping round of rain from its fields: `look`, `pattern`, `motion` (empty = each kind's own), `curve`, `seconds`, `rate` (objects per second at the start), `waveEvery`, `kinds` (comma list), `areaCenter`, `areaSize` ({width, height, depth}), `down`, `warning`, `entry`, `maxAlive`, `speedScale`, `loop`.
## The play area
A rectangle in world space: `center`, `width` (across), `height` (along "up"), `depth` (thickness; swirl and float use it), and `down`, the direction things fall. `{0,-1,0}` is a vertical field seen by a fixed camera looking along -Z; for a top-down area pass the screen's down, e.g. `{0,0,1}` (depth then runs along world Y). `across` may be given to override the left-to-right axis. Objects start just outside the edge their motion enters from (above for falling motions, below for `arc` and `rise`, beside for the `sides` pattern) and escape when they leave by any edge (`ev.edge` = `bottom`, `top`, `left`, `right`, or `timeout` after 45 s).
## API
| Call | Where | What |
|---|---|---|
| `Skyfall.VERSION` | any | `"1.0.4"` |
| `Skyfall.defineKind(name, def)` | **every peer** | `def` = `{ build = function(entity, look) end?, model?, material?, tint?, shape?, motion?, speed?, radius?, data? }`. `build` gets the object's local body entity to parent your visuals under (it is moved for you); or give a `model` / `material`; or a built-in `shape`. Built-in kinds orb, star, gem, bubble, balloon, rock, fruit, bomb, drop, leaf exist already. |
| `Skyfall.director(opts) -> handle` | any | Creates (host) or finds the synced director named `opts.name` (default `"Skyfall"`) and makes it current. Options: `area`, `look`, `warning`, `entry`, `curve`, `pattern`, `motion`, `maxAlive`, `speedScale`, `kinds`, `autoRun`. Handle: `h.name`, `h:id()`, `h:entity()`, `h:isAuthority()`, `h:fields()`. |
| `Skyfall.spawn(kind, { motion?, x?, y?, vx?, speed?, delay?, data?, look?, radius? }) -> entity?` | authority | One object. `x` 0..1 across, `y` 0..1 up (default: the motion's own start edge), `vx` sideways m/s. `nil` elsewhere or at `maxAlive`. |
| `Skyfall.wave({ pattern, kinds, kind?, count, gap, motion?, speed?, lanes?, data?, delay? }) -> { entity }` | authority | One wave now. |
| `Skyfall.run(schedule, opts?)` | authority | A list of waves (`{ at = seconds, pattern = ..., ... }`; missing `at` = previous + `opts.every`), or a round `{ seconds, waves, curve, every, strength?, loop? }` that fires the next wave template every `every` seconds with count, speed and pace scaled by the curve. The schedule is stored in synced fields, so a new host carries on. |
| `Skyfall.stopAll()` | authority | Stops the schedule; objects in play keep going. |
| `Skyfall.clear()` | authority | Ends everything in play (`removed`, reason `"cleared"`). |
| `Skyfall.remove(entity, reason?)` | any | Ends one object now (`removed`, reason default `"removed"`); forwarded to the authority from other peers. |
| `Skyfall.alive() -> { entity }` | any | Objects in play on this peer. |
| `Skyfall.positionOf(entity) -> {x,y,z}` | any | This peer's computed position now. |
| `Skyfall.infoOf(entity)` / `Skyfall.isObject(entity)` | any | `{ kind, data, motion, look, appearsAt, ended, radius }`. |
| `Skyfall.on(name, fn)` | any | `"spawned"`, `"escaped"`, `"removed"` or `"*"` (`fn(name, ev)`). `ev = { entity, id, kind, data, position, motion, director, reason?, edge?, appearsAt }`. Returns a connection with `:Disconnect()`. |
| `Skyfall.isAuthority()` / `Skyfall.running()` | any | Whether this peer drives; whether a schedule runs. |
| `Skyfall.setLook(name)` / `Skyfall.configure(opts)` | authority | Switch look (objects in play too) / change director settings. |
| `Skyfall.area()` | any | The current play-area frame `{ c, ax, up, dz, w, h, d }`. |
| `Skyfall.looks() motions() patterns() entries() warnings() curves() shapes()` | any | The style names. |
| `Skyfall.stats()` | any | Event counts and alive count on this peer. |
Each object's synced `SkyfallObject` component also exposes its `kind` and `gameData` fields directly, for kits that hold the entity (e.g. a touch-target kit): `entity.component.get(Skyfall.OBJECT).kind`.
Gallery demo: `require("skyfallKit.gallery").start({ center = {0,6,0}, cycleLooks = true })`, `.stop()`.
## Multiplayer rules
- **One authority**: the peer that owns the director entity (the host creates it with `entity.spawnSynced`; with host migration the new owner takes over, schedule included). Only it spawns, runs schedules and clears. Other peers' `spawn` / `wave` / `run` return nil / `{}` / false and do nothing.
- **Objects carry parameters, not transforms.** Each object is a synced entity with a `SkyfallObject` component holding its start time on `multiplayer.sessionTime()`, start point, motion, speed, seed and the play area. The synced entity never moves; every peer computes the pose every frame and moves a local body child, so motion is smooth everywhere and no poses are streamed.
- **Endings are fields.** The object's owner sets `endReason` (escaped / removed / cleared / your reason) and despawns it 0.3 s later; every peer fires the event from that field. An entity despawned by anything else fires `removed` with reason `"despawned"` on every peer and simply drops out of `alive()`.
- **Late joiners** receive live objects with the room snapshot; each fires `spawned` on them as it arrives.
- **defineKind on every peer**: a kind's `build` is a function and cannot cross the network.
## Performance
- Network: one synced entity per object, one message when it spawns and one when it ends. No per-frame traffic.
- CPU: measured on an Android phone with 40 objects alive: about 0.06 to 0.1 ms per object per frame (around 3 ms for 40), most of it the per-component update and three transform writes. `maxAlive` (default 40) caps it.
- Draw: 2 to 6 primitive meshes per object for the placeholder looks; a game's own `build` decides its own cost.
## Known limitations
- Motion is deterministic per peer, but peers agree only to the accuracy of the session clock (typically a few tens of milliseconds), which is fine for catching but not for frame-exact physics.
- Objects do not collide with anything; hit tests are the game's (use `Skyfall.positionOf` or the body entity).
- `fadeIn` fades the tint in from white (the placeholder materials are opaque), not the opacity.
## Guides in this package
- `how-to-make-things-fall-from-the-sky-in-waves-for-an-arcade-game` — the concepts, every style, schedules, curves, multiplayer and performance.
- `example-build-a-catch-the-falling-stars-game` — a step-by-step small game with lives, score and a difficulty ramp.
## Version history
- **1.0.4**: runs on spawnerKit 1.2.7 (its README and version label now match; no code change in either kit).
- **1.0.3**: runs on spawnerKit 1.2.5, which keeps every pooled object (prewarmed ones too) fully asleep until it is used and stops refused-write warnings on peers that do not own an enemy.
- **1.0.2** — declares spawnerKit (its difficulty curves) as a dependency, so installing skyfallKit on its own brings spawnerKit along.
- **1.0.1** — an entry effect is no longer spawned under an object whose synced entity is already gone.
- **1.0.0** — first release.
# Fingertip: Touch Feedback and Gesture Hints Kit (fingertipKit)
Touch feedback for phone and tablet games. Installing it gives a world:
- **Tap ripples** wherever a finger lands.
- **Finger trails** that follow every moving finger (multi-touch) or a mouse drag.
- **Button press effects** for the game's own UI buttons, plus a helper that builds a ready button (at least 64 points) with the effect applied.
- **Animated gesture hints**: a little SVG hand that shows the player what to do (tap, double tap, hold, swipe, flick, drag, pinch: seven gestures), shows only the first time if you want, and goes away by itself when the player does the gesture.
- **Five looks** that switch all of the above, a colour palette and a soft tap sound with one setting.
Everything is drawn on one overlay screen of the player's own peer. The overlay **never takes a touch** (every node is `pointerEvents = "none"`, the hand pictures are background images and captions are a non-interactive canvas), the **left mouse button acts as a finger** on desktop, and in **multiplayer every player sees only their own fingers** and hints.
Version **1.1.1**.
**What is in it, by count:** 7 tap ripples, 7 finger trails, 4 button press effects, 4 hint hands, 7 gesture hints (tap, doubleTap, hold, swipe, flick, drag, pinch) and 5 looks (cartoon, minimal, neon, pixel, pastel) that restyle all of them at once. `TF.ripples()`, `TF.trails()`, `TF.presses()`, `TF.hands()`, `TF.hintKinds()` and `TF.looks()` list them.
**Changelog**
- **1.1.1**: runs on the current built-in library (its sound references are pinned to the 2026-11-22 builtin release); no change in behaviour.
- **1.1.0**: renamed from touchFeedbackKit to fingertipKit ("Fingertip: Touch Feedback and Gesture Hints Kit"): `require("fingertipKit.feedback")`, components `fingertipKit.TouchFeedback` and `fingertipKit.TouchFeedbackGallery`. New **flick** gesture hint (a short, quick throw in a direction: a faster, shorter hand stroke with speed lines) and a flick recogniser (`TF.onGesture` reports `flick` with `dir` and `speed` for a swipe released within 0.25 s at 600+ points per second; it still reports `swipe` too). The gallery lays out every section with its own heading row and labels inside their cells, and takes `insetBottom` to keep a strip free for the host's own UI.
- **1.0.0**: first release (as touchFeedbackKit).
## Install
Search ZeroMind for **fingertipKit** (or "tap ripple", "gesture hint hand") and install the package by its guid with `zeromind.install`; it lands at `/source/fingertipKit.package`.
## Quick start
No code: add the **TouchFeedback** component to any entity in your scene and pick a `look`. In play every player gets ripples, trails and the look's sound.
In code:
```lua
local TF = require("fingertipKit.feedback")
TF.start({ look = "pastel" }) -- idempotent, local player only
-- teach a gesture the first time this player plays (saved per player)
TF.hintOnce("jump", "swipe", { x = 0.5, y = 0.75, frac = true, dir = "up", caption = "Swipe up to jump" })
-- a menu button with the look's press effect; the click arrives in the
-- onCallback of the component that registers the screen
ui.registerScreen("menu", { type = "vertical", style = { alignItems = "center", padding = 24 }, children = {
TF.button({ id = "playBtn", text = "Play", icon = "▶", onClick = "play" }),
} })
```
Call `TF.start` from a component hook or plain code (not after a `task.wait`): it also prepares the local sound voices, which need a live component context.
## Looks
| look | ripple | trail | press | hand | sound | palette |
|---|---|---|---|---|---|---|
| `cartoon` | starBurst | comet | pop | cartoonGlove | pop | sunny yellow, red, sky blue, ink outlines |
| `minimal` | ring | ribbon | pushDown | minimalDot | tick | white and calm blue |
| `neon` (sci-fi) | softGlow | neon | glow | outlinedFinger | blip | cyan, magenta, violet glow |
| `pixel` | pixelSquare | pixels | pushDown | pixelHand | chip | 8-bit yellow, red, blue, monospace |
| `pastel` (cozy) | splash | sparkles | wobble | cartoonGlove | bell | pink, mint, lavender |
Any individual setting overrides the look's pick (`TF.start({ look = "neon", trail = "bubbles" })`, `TF.setRipple("inkBlot")`; `nil` goes back to the look's).
## Every style
- **Ripples** (`ripple`): `ring`, `splash`, `starBurst`, `inkBlot`, `pixelSquare`, `softGlow`, `confetti`.
- **Trails** (`trail`): `ribbon`, `sparkles`, `comet`, `chalk`, `neon`, `bubbles`, `pixels`.
- **Press effects** (`press`): `pop`, `glow`, `wobble`, `pushDown`.
- **Hands** (`hand`): `cartoonGlove`, `minimalDot`, `outlinedFinger`, `pixelHand` (SVG pictures in `hands/`).
- **Hint kinds**: `tap`, `doubleTap`, `hold`, `swipe` (dir `left`/`right`/`up`/`down`), `drag` (A to B), `pinch` (dir `in`/`out`).
- **Tap sounds**: `pop`, `tick`, `blip`, `chip`, `bell` (synthesised, in `sounds/`; `sound = false` turns them off).
## API
```lua
local TF = require("fingertipKit.feedback")
TF.VERSION -- "1.1.1"
TF.start(opts?) TF.stop() TF.running()
-- opts: look, ripple, trail, press, hand, sound (bool), volume (0..1), layer (900),
-- scale (1), ripples (bool), trails (bool), mouse (bool), controls (bool),
-- edit (bool: also run in edit mode). TF.start() with no table keeps the current settings.
TF.setLook(name) TF.setRipple(style) TF.setTrail(style) TF.setPress(style) TF.setHand(style)
TF.setSound(on, volume?)
TF.looks() TF.ripples() TF.trails() TF.presses() TF.hands() TF.hintKinds()
TF.settings() -- current settings + what the look resolves to
TF.ripple(x, y, opts?) -- manual ripple at a UI logical point; opts.style/color/scale
TF.button({ id, text, icon?, onClick, style?, width?, height?, press?, fontSize? }) -> node
TF.pressStyle(baseStyle, pressName?) -> style -- adds hover/active states + transition
local h = TF.hint(kind, { x, y, frac?, world?, dir?, toX?, toY?, caption?, timeout?, hand?, scale? })
h:stop() h:isActive()
TF.hintOnce(key, kind, opts) -> handle? -- nil when this player has already seen it
TF.resetHints() TF.clearHints()
TF.onGesture(fn(kind, info)) -> unsubscribe -- tap, doubleTap, hold, swipe, flick, drag, pinch
TF.virtualTouch(key, x, y, opts?) TF.virtualRelease(key) -- a scripted "ghost" finger
TF.stats() -- counters: contacts, ripples, trails, gestures, hints, rebuild cost
```
Coordinates are UI logical points in `ui.screenSize()` space (what `ui.fromViewport` returns). With `frac = true`, `x`, `y`, `toX`, `toY` are 0..1 of the screen. `world = {x, y, z}` makes a hint follow a world position through `worldToScreen` (then `toX`/`toY` are an offset added to the projected point). A hint's `timeout` defaults to 12 seconds (`0` keeps it until it is performed or stopped). Hints are dismissed by the matching gesture anywhere on screen: a `tap` hint by a tap or double tap, a `swipe` hint by a swipe in its `dir`, a `drag` hint by a drag (or swipe) ending within 100 points of its target, a `pinch` hint by a pinch in its `dir`.
`hintOnce` remembers what each player has seen in that player's saved data (`runtime_data.player(localId)` under `fingertipKit/hints/<key>`), falling back to this session when the player has no id.
## Parts
- `feedback` module: the API above; one overlay screen, a per-frame input poll (`Zin.touch.slots()` plus the left mouse button), gesture recognition, hints, persistence.
- `looks` module: the five looks, palettes and colour helpers.
- `fx` module: builds the ripple and trail nodes.
- `hints` module: builds the hint nodes and resolves the hand pictures.
- `sound` module: synthesises (`Sound.bake()`, authoring) and plays the tap sounds on local voices.
- `TouchFeedback` component: zero-code start (fields `look`, `ripple`, `trail`, `press`, `hand`, `sound`).
- `TouchFeedbackGallery` component: a live showcase of every look, ripple, trail, press effect and hint, with look buttons. Put it on an entity and press play.
- Guides: `how-to-show-where-the-player-touched-the-screen-and-teach-gestures` and `example-build-a-small-touch-game-with-tap-ripples-and-gesture-hints`.
## Multiplayer
The kit is purely local: each peer reads its own touches and draws on its own screen, and nothing is replicated. Every player in the world gets their own feedback, sees only their own fingers, and `hintOnce` is remembered per player. Put the `TouchFeedback` component in the scene (it runs on every peer) or call `TF.start` from code that runs on every peer.
## Performance
The overlay is one screen whose tree changes only when an effect starts or ends; every effect animates with a CSS `animation`, so nothing is re-laid-out per frame for motion. Live effects are capped (12 ripples, 64 trail particles), trail particles are spaced by distance and limited to the frame rate, and world-following hints are only rebuilt when they move. Measured on an Android tablet with two fingers dragging: about 0.07 ms of Luau per frame for the poll and 0.1 to 0.4 ms for a tree update.
## Known limits
- Effects draw in the camera's picture (the game view), so in the editor they appear inside the Scene panel, and on screens with an on-screen look zone a finger held by that zone still gets feedback (set `controls = false` to skip contacts any on-screen control holds).
- Gesture recognition is the kit's own simple recogniser (thresholds in logical points); use `Zin.gestures` if your game needs finer control, and `TF.onGesture` if you want to react to what the kit recognised.
# targets
The touchTargetsKit front door: `require("touchTargetsKit.targets")`. `start`/`stop` recognition on this client, `add`/`remove` targets, and listen with `onHit` (every peer, once per resolved hit), `onMiss`, `onHoldProgress` and `onDrag` (local). It reads touches (`Zin.touch.slots()`) and the mouse each frame, tests them against every target's projected screen circle (fingertip-sized minimum radius), turns gestures (tap, doubleTap, hold, swipe, drag, any) into claims, resolves claims on the target's authority (its owner, else the host) over `multiplayer.send`, broadcasts hits, plays reactions and draws hold rings and highlights through the overlay. Game code and the TouchTarget component call it; the package README documents every call.
# gallery
A demo for touchTargetsKit: `require("touchTargetsKit.gallery").spawn(opts)` in play spawns one tap target per reaction (pop, shatter, squash, spinAway, fade, sparkle, none) and one hold target per hold ring (ring, fill, petals, segments, dots), laid across the screen in front of the camera (or around `opts.origin`), respawning a second and a half after each hit. Options: look, origin, spacing, size, distance, holdSeconds, synced (host spawns synced entities), respawn. `clear()` removes them.
# feedback
The fingertipKit front door: `require("fingertipKit.feedback")`. `start(opts)` puts up one non-interactive overlay screen on this player's peer and polls the player's own touches (and the left mouse button) every frame: a finger landing plays a tap ripple and the look's tap sound, a moving finger leaves a trail, and the kit's recogniser reports tap, doubleTap, hold, swipe, flick, drag and pinch (`onGesture`), which also dismiss the matching gesture hints. It holds the settings (look and per-style overrides), builds look-styled buttons (`button`, `pressStyle`), shows hints (`hint`, `hintOnce` with per-player memory, `clearHints`, `resetHints`), manual ripples (`ripple`), scripted ghost fingers (`virtualTouch`) and test counters (`stats`). Game code, the TouchFeedback component and the gallery call it; the package README documents every call.
# TouchTarget
Makes the entity it is on a touch target with no code: in play it starts touchTargetsKit on the client and registers its own entity with its fields (gestures as a comma-separated list, radius, holdSeconds, kind, points, reaction, holdRing, highlight, consume, and an optional look). Needs nothing else on the entity beyond something to see (a Model). Changing a field re-registers it. Read the hits with `require("touchTargetsKit.targets").onHit`.
# overlay
The pooled instanced draws touchTargetsKit draws every indicator with: hold rings, glow and outline highlights and shatter shards. Four draws (juiceKit's glow or solid particle material, sphere or cube), each fed per frame from two GPU buffers; `begin`, `push` an instance (centre, three scaled basis columns, colour, glow gain), `flush`. Nothing is spawned per indicator. Called by the targets and reactions modules.
# reactions
The hit reactions of touchTargetsKit: `pop`, `shatter`, `squash`, `spinAway`, `fade`, `sparkle`, `none`. `play(name, entity, opts)` animates the entity's transform on the peer that may write it, plays the matching juiceKit effect locally on every peer, spawns overlay shards for `shatter`, and despawns (or hides) a consumed target at the end. The targets module calls it when a hit arrives; `step` advances it each frame.
# state
A table that outlives a hot reload of touchTargetsKit's modules: the targets module keeps its registered targets, listeners and settings here, and an older copy of it reads `gen` to stand down when a newer one loads. Internal to the kit.
# styles
The names of every touchTargetsKit reaction, hold ring, highlight, look and gesture, and each look's palette (ring and highlight colours, shard colours, material, dot shape, stroke, glow gain, pixel snap, and the juiceKit look its hit effects use). Pure data read by the targets, reactions, gallery and TouchTarget assets.
# SkyfallDirector
The authority for one play area. Put it on an entity in a scene (or let `Skyfall.director` create a synced one): the peer that owns it spawns objects and runs the schedule; other peers read its fields. With `autoRun` on (the default when placed by hand) it starts a looping round of rain from its own fields when play begins — look, pattern, motion, curve, seconds, rate, waveEvery, kinds (comma list), areaCenter, areaSize, down, warning, entry, maxAlive, speedScale — so a scene gets falling placeholder objects with no code. Methods: `isAuthority()`, `aliveCount()`.
# SkyfallObject
One falling, drifting or rising object. The spawner adds it to a synced entity; you do not add it yourself. It carries only motion parameters (`t0` on the session clock, start point, `motion`, `speed`, `seed`, the play area) plus `kind` and `gameData`, so any peer can read what it is. The synced entity never moves: every peer computes the pose each frame and moves a local body child, shows the warning marker before it appears and plays its entry effect. The owner watches it leave the area, sets `endReason` and despawns it shortly after; every peer fires `spawned` / `escaped` / `removed` from these fields. Methods: `position()`, `finish(reason, edge)`.
# core
Shared state and maths for skyfallKit on this peer: the kind registry, event listeners and emit, the registries of live objects and directors (filled by the components), the play-area frame (centre, across / up / depth unit axes, sizes) and its conversion to world space, quaternion helpers, the session clock (`multiplayer.sessionTime`) and the ownership rule (offline every entity is ours; an unowned entity belongs to the host). State lives in `modules.state()` so hot reloads keep kinds, listeners and live objects. The skyfall module, the spawner and both components call it.
# curves
Difficulty over a round for skyfallKit. `at(name, progress, strength)` turns progress through the round (0..1) into count, speed and pace multipliers plus a rest flag, using spawnerKit's difficulty curves (`~spawnerKit.curves`) under round-friendly names: linear (steady), easeIn (steep), steps (stepped), waves (breather) and flat. spawnerKit's own names work too. The spawner applies it to every wave of a round.
# gallery
A demo of skyfallKit that shows every motion style side by side. `require("skyfallKit.gallery").start({ center = {0,6,0}, look = "neon", cycleLooks = true })` on the authority, in play, makes its own director (`SkyfallGallery`) and every couple of seconds drops one object per motion into eight columns, left to right: drop (orb), zigzag (gem), swirl (star), float (leaf), arc (fruit), bounce (bomb), rise (balloon), dart (rock). `cycleLooks` switches between the five looks each round. `stop()` clears its objects and removes its director; `running()` says whether it is on. Runtime only; nothing is saved into a scene.
# looks
Placeholder visuals for skyfallKit in five looks (cartoon: bright and outlined; minimal: single matte shapes; neon: glowing with a halo; pixel: blocky; pastel: soft colours). Builds ten built-in shapes (orb, star, gem, bubble, balloon, rock, fruit, bomb, drop, leaf) from the engine's primitive meshes as local children of an object, the warning markers (ring, arrow, glow) and the entry effects (popIn, fadeIn, streak, sparkle). Games replace a kind's look with their own `build(entity, look)` or `model` / `material`.
# motions
The eight motion styles of skyfallKit as pure functions of time and synced parameters: drop (straight down, gently accelerating), zigzag, swirl (spiral down through the depth), float (wobbly leaf drift), arc (thrown up from below, then falls), bounce (three bounces on the floor, then through it), rise (bubbles and balloons going up) and dart (fast diagonal streak). `eval(motion, t, params)` gives an area-local pose; `exitEdge` says when an object has left the area and by which edge; `entryPoint` finds where it first comes into view (for warning markers). Every peer runs the same maths, which is why objects need no transform streaming.
# patterns
The eight wave patterns of skyfallKit: rain (random across the width), line (a row), vee, burst (from one point, fanning out), spiral, sides (in from the left and right edges), lanes (fixed columns) and fountain (thrown up from below the centre). `layout(name, count, { gap, lanes?, motion?, rand })` returns where each object starts across the area (0..1), optional height and sideways speed, and its delay within the wave. Called by the spawner on the authority.
# skyfall
The skyfallKit front door: `local Skyfall = require("skyfallKit.skyfall")`. Defines kinds of falling things (`defineKind`, on every peer), creates or finds the synced director that is the one authority for a play area (`director`), spawns single objects and whole waves on the authority (`spawn`, `wave`), runs schedules that ramp along a difficulty curve (`run`, `stopAll`), removes objects (`remove`, forwarded to the authority from other peers; `clear`), reads what is in play on any peer (`alive`, `positionOf`, `infoOf`, `isObject`, `area`), and fires `spawned`, `escaped` and `removed` on every peer (`on`). Style lists: `looks`, `motions`, `patterns`, `entries`, `warnings`, `curves`, `shapes`; `setLook` and `configure` change the current director. The package README documents every call.
# spawner
The authority's side of skyfallKit: `spawn` makes one synced SkyfallObject entity carrying its motion parameters (respecting `maxAlive`), `wave` lays a wave out with a pattern and spawns it, and `start` / `step` run a director's schedule — a list of waves at times, or a round that fires a wave every few seconds and scales count, speed and pace along a curve. Called by the skyfall module and the SkyfallDirector component on the peer that owns the director.
# TouchFeedback
Zero-code touch feedback. Put it on any entity in a scene; in play it calls `TF.start` on every peer for that peer's own screen, so each player sees tap ripples where their own fingers land, finger trails, and the chosen look for buttons and gesture hints. Fields: `look` (cartoon, minimal, neon, pixel, pastel), and `ripple`, `trail`, `press`, `hand` (leave empty to follow the look), `sound` (the look's soft tap sound). Needs no sibling components. Removing the component stops the feedback it started.
# TouchFeedbackGallery
A live showcase of fingertipKit for testing, choosing a look and taking a cover picture. Put it on any entity and press play: on this player's screen it shows look buttons and press-effect buttons (made with `TF.button`, tap them to switch), every ripple style firing in its own cell, every trail style drawn by a virtual finger, and every gesture hint animating with the current hand. Your own taps and drags on top get the current look's feedback. Fields: `look` (the look it opens on), `sound`, and `insetBottom` (points at the bottom it leaves free for the host's own UI, such as a navigation bar or a score badge). Each section (ripples, trails, the seven gesture hints) has its own heading row, and every name sits inside its own cell. Needs no sibling components; removing it takes the gallery down and stops the feedback.
# fx
Builds the UI nodes for fingertipKit's tap ripples (`ripple`: ring, splash, starBurst, inkBlot, pixelSquare, softGlow, confetti) and finger-trail particles (`trail`: ribbon, sparkles, comet, chalk, neon, bubbles, pixels). Every node is an absolutely placed `vertical` box with `pointerEvents = "none"`, a unique id and a one-shot CSS `animation`, so the overlay never takes a touch and each effect animates from the moment it is added without any per-frame update. Returns the node and its lifetime; the feedback module places, caps and expires them.