onGamepadButtonDown(btn: KGamepadButton | KGamepadButton[], action: (btn: KGamepadButton, gamepad: KGamepad)=>void): KEventController

Register an event that runs every frame when certain gamepad buttons are held down.

parambtn- The button(s) to listen for. See

paramaction- The function that is run while certain gamepad buttons are held down.

// when button is being held down
onGamepadButtonDown("rtrigger", (gp) => {
    car.addForce(Vec2.fromAngle(car.angle).scale(10));
});

returnsThe event controller.

sincev3001.0

onGamepadButtonDown(action: (btn: KGamepadButton, gamepad: KGamepad)=>void): KEventController

Register an event that runs every frame when any gamepad buttons are held down.

paramaction- The function that is run while any gamepad buttons are held down.

// when button is being held down
onGamepadButtonDown((btn, gp) => {
    if (btn == "rtrigger") {
        car.addForce(Vec2.fromAngle(car.angle).scale(10));
    } else if (btn == "ltrigger") {
        car.addForce(Vec2.fromAngle(car.angle).scale(-5));
    }
});

returnsThe event controller.

sincev3001.0

kaplay logo

Misc

Layer