Skip to content

Hooks

Solidion provides hooks (L1a layer) that integrate Phaser features with SolidJS reactivity.

Animate properties with Phaser tweens, controlled reactively.

const { value, play, stop } = useTween({
from: 0,
to: 100,
duration: 1000,
ease: "Sine.easeInOut",
});
<sprite x={value()} y={300} texture="ball" />;

Physics-based spring animations.

const { value } = useSpring({
target: () => targetX(),
stiffness: 120,
damping: 14,
});
<sprite x={value()} y={300} texture="player" />;

Declarative finite state machines for game logic.

const { state, send } = useStateMachine({
initial: "idle",
states: {
idle: { on: { JUMP: "jumping" } },
jumping: { on: { LAND: "idle" } },
},
});

Per-frame update loop integrated with SolidJS lifecycle.

useFrame((time, delta) => {
setX((x) => x + speed * delta);
});