Optionaloptions: InputPluginOptions<A, G>const ecs = ECSpresso.create()
.withPlugin(createInputPlugin({
actions: {
jump: { keys: [' ', 'ArrowUp'], gamepadButtons: [{ pad: 0, button: 0 }] },
shoot: { keys: ['z'], pointerButtons: [0] },
},
players: {
p1: { jump: { keys: [' '] }, shoot: { keys: ['z'] } },
p2: {
jump: { gamepadButtons: gamepadButtonsOn(0, 0) },
shoot: { gamepadButtons: gamepadButtonsOn(0, 2) },
},
},
}))
.build();
const input = ecs.getResource('inputState');
if (input.actions.justActivated('jump')) { ... } // any source
if (input.player('p1')?.actions.isActive('jump')) { ... } // just player 1
if (input.gamepads[0].isDown(0)) { ... } // raw pad 0 A-button
Create an input plugin for ECSpresso.
Provides:
definePlayer,player(id))