feat: joystick use
This commit is contained in:
parent
ac3a980a43
commit
827e9b6d67
|
@ -67,9 +67,17 @@ const PlayUi = () => {
|
|||
const inputNormalizer = new InputNormalizer();
|
||||
inputNormalizer.listen(window.document.body);
|
||||
selfEntity.listenForInput(inputNormalizer);
|
||||
selfEntity.actionRegistry.setTransformerFor('UseItem', (type) => (
|
||||
(-1 !== ['buttonPress', 'keyDown'].indexOf(type)) ? selfEntity.activeSlotIndex : -1
|
||||
));
|
||||
selfEntity.actionRegistry.setTransformerFor('UseItem', (type, value) => {
|
||||
switch (type) {
|
||||
case 'joystick':
|
||||
return value === 0 ? -1 : selfEntity.activeSlotIndex;
|
||||
case 'buttonPress':
|
||||
case 'keyDown':
|
||||
return selfEntity.activeSlotIndex;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
});
|
||||
const inputHandle = setInterval(() => {
|
||||
const actionStream = selfEntity.drainInput();
|
||||
if (actionStream.length > 0) {
|
||||
|
|
|
@ -93,6 +93,7 @@ export default (latus) => class ServerJoin extends Join() {
|
|||
{type: 'key', index: 'd'},
|
||||
],
|
||||
UseItem: [
|
||||
{type: 'joystick', index: 4, axis: 1},
|
||||
{type: 'button', index: 0},
|
||||
{type: 'key', index: 'ArrowLeft'},
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue
Block a user