Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

Joystick

A game that lists characters() needs no Joystick: the engine draws the player’s stick on a phone, as Touch controls says. Place one to move, resize or hide that stick, or to steer something of the game’s own.

<Joystick> is the stick a thumb drags. It stands in the screen’s bottom-left slot, drawn for a coarse pointer only, and clear of the corner by a thumb’s reach; slot moves it. The slots keep clear of the device’s safe area and the player app’s controls, so a game names no position. A thumb that lands just outside the ring still catches it, and the ring grows to show what it caught. className styles it, such as size-40 for a stick larger than its default size-32, and grabMargin sets how far past the ring a thumb catches it.

It takes one of two things:

  • input, a vector input such as characters.inputs.move: the stick holds the input while a thumb drags it, added to its keys, and takes the place of the stick the engine draws for that input. Its label is the declaration’s. hidden draws nothing and still takes that place.
  • onSteer, a function that hears where the thumb is on the unit disc, x right and y up the screen, and (0, 0) as the thumb lifts. onRelease runs after that last report. Such a stick binds nothing and replaces no stick the engine draws.

<Joystick input={characters.inputs.move} slot={Slot.Left} /> moves the player’s stick to the left edge. Its props are in JoystickProps.