onGamepadStick(stick: GamepadStick, action: (value: Vec2, gameepad: KGamepad)=>void): KEventController

Register an event that runs when the gamepad axis exists.

paramstick- The stick to listen for. See

paramaction- The function that is run when a specific gamepad stick is moved.

// player move
let player = add([
    pos(center()),
    sprite(`bean`),
]);

// when left stick is moved
onGamepadStick("left", (stickVector, gp) => {
    player.move(stickVector.x, 0);
});

returnsThe event controller.

sincev3000.0

kaplay logo

Misc

Layer