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