Haptics
Haptics plays a short device vibration ("buzz") for tactile feedback —
a tap confirmation, a success chime, an error shake. The host owns the
effect: the Castle mobile app plays a native haptic, the website uses the
browser's vibration API where available, and the dev server or an
unsupported device does nothing.
Haptics.play(style): Promise<HapticsResult>
Plays a haptic in one of seven styles:
'light','medium','heavy'— impact taps of increasing strength.'selection'— a light tick, e.g. moving through options.'success','warning','error'— notification patterns.
Usually you don't await it — fire it and move on:
button.onclick = () => {
Haptics.play("light");
doTheThing();
};
The returned HapticsResult has a status, if you want to branch on it:
'triggered'— the host played (or accepted) the haptic.'unavailable'— this host or device can't play haptics (e.g. the dev server, or a browser with no vibration support). Nothing was played.
Haptics respect the player's settings — if a player has muted haptics,
play does nothing and resolves 'unavailable'. Rapid repeated calls may
be coalesced, so it's safe to call on frequent events.