1681-engine / index / AimEnd
Type Alias: AimEnd ​
type AimEnd = "tap" | "cast" | "cancel";Defined in: src/input/AimGesture.ts:19
The drag-to-aim gesture of a touch skill button (the MOBA way), kept pure so it can be tested. Pressing an aimed button opens a circle round it with a knob under the thumb; where the knob sits in that circle is where the skill goes. A press that never wanders past the tap slop is a tap (the game casts it the way a tap always does: at the locked target, the nearest enemy, the facing). Letting go over a cancel zone casts nothing; letting go with the knob back on the button casts as a tap, or cancels when centreCancels (the one way to cancel when there is no zone).
The thumb gets a longer slop in the first pressMs of a press: a hard press slides as it lands, and a quick tap that slid past the plain slop became a drag that flew wherever the slide pointed.
const g = new AimGesture({ radius: 90, centreCancels: !hasCancelZone });
// pointermove: g.move(dx, dy, overCancelZone, now - downAt)
// pointerup: const end = g.up(); // 'tap' | 'cast' | 'cancel'
// while g.aiming, draw the aim from aimPoint(caster, shape, g.share, facing)