Hooks
Hooks API
Section titled “Hooks API”React hooks provided by Strata packages.
Core Hooks
Section titled “Core Hooks”useAnimationBlend
Section titled “useAnimationBlend”Blend multiple animations with weighted mixing.
import { useAnimationBlend } from '@strata-game-library/core';
function Character() { const { blend, setWeight } = useAnimationBlend({ idle: idleAnimation, walk: walkAnimation, run: runAnimation, });
useEffect(() => { setWeight('walk', velocity / maxSpeed); }, [velocity]);
return <Character animation={blend} />;}Returns
Section titled “Returns”| Property | Type | Description |
|---|---|---|
blend | Animation | Blended animation |
setWeight | (name: string, weight: number) => void | Set animation weight |
getWeight | (name: string) => number | Get current weight |
useFurInteraction
Section titled “useFurInteraction”Handle touch/mouse interaction with fur.
import { useFurInteraction } from '@strata-game-library/core';
function InteractiveFur() { const { onPointerMove, deformation } = useFurInteraction();
return ( <FurMesh onPointerMove={onPointerMove} deformation={deformation} /> );}Returns
Section titled “Returns”| Property | Type | Description |
|---|---|---|
onPointerMove | (event: PointerEvent) => void | Event handler |
deformation | DeformationMap | Current deformation state |
reset | () => void | Reset deformation |
Mobile Plugin Hooks
Section titled “Mobile Plugin Hooks”useDevice
Section titled “useDevice”Get device information (React Native / Capacitor).
import { useDevice } from '@strata-game-library/capacitor-plugin/react';
function Game() { const device = useDevice();
return ( <div style={{ paddingTop: device.safeAreaInsets.top }}> <p>Platform: {device.platform}</p> <p>Type: {device.deviceType}</p> <p>Input: {device.inputMode}</p> </div> );}Returns
Section titled “Returns”| Property | Type | Description |
|---|---|---|
platform | string | ’ios’, ‘android’, ‘web’, etc. |
deviceType | string | ’mobile’, ‘tablet’, ‘desktop’ |
inputMode | string | ’touch’, ‘keyboard’, ‘gamepad’ |
orientation | string | ’portrait’, ‘landscape’ |
safeAreaInsets | object | Safe area for notches |
useInput
Section titled “useInput”Get unified input state (React Native / Capacitor).
import { useInput } from '@strata-game-library/capacitor-plugin/react';
function Game() { const { leftStick, rightStick, buttons, isPressed } = useInput();
useFrame(() => { player.move(leftStick.x, leftStick.y); });
if (isPressed('jump')) { player.jump(); }
return <Player />;}Returns
Section titled “Returns”| Property | Type | Description |
|---|---|---|
leftStick | { x: number, y: number } | Left joystick (-1 to 1) |
rightStick | { x: number, y: number } | Right joystick |
buttons | Record<string, boolean> | Button states |
triggers | { left: number, right: number } | Trigger values |
isPressed | (button: string) => boolean | Check button |
useHaptics
Section titled “useHaptics”Trigger haptic feedback (React Native / Capacitor).
import { useHaptics } from '@strata-game-library/capacitor-plugin/react';
function Game() { const { light, medium, heavy, custom, isSupported } = useHaptics();
const handleHit = () => { if (isSupported) medium(); };
return <GameScene onHit={handleHit} />;}Returns
Section titled “Returns”| Property | Type | Description |
|---|---|---|
light | () => Promise<void> | Light haptic |
medium | () => Promise<void> | Medium haptic |
heavy | () => Promise<void> | Heavy haptic |
custom | (options: HapticsOptions) => Promise<void> | Custom haptic |
isSupported | boolean | Device supports haptics |
useControlHints
Section titled “useControlHints”Get localized control hints based on input mode.
import { useControlHints } from '@strata-game-library/capacitor-plugin/react';
function HelpOverlay() { const hints = useControlHints();
return ( <div> <p>Move: {hints.movement}</p> <p>Look: {hints.camera}</p> <p>Action: {hints.action}</p> </div> );}Returns
Section titled “Returns”| Property | Type | Description |
|---|---|---|
movement | string | Movement hint text |
camera | string | Camera hint text |
action | string | Primary action hint |
useStrata
Section titled “useStrata”All-in-one hook for Capacitor plugin.
import { useStrata } from '@strata-game-library/capacitor-plugin/react';
function Game() { const { deviceInfo, safeArea, inputMode, orientation, triggerHaptics, } = useStrata();
return <GameScene />;}Related
Section titled “Related”- Components - React components
- Core Functions - Utility functions
- Types - TypeScript types