refactor: listen to app node for events
This commit is contained in:
parent
9324fd26ee
commit
5b133038b2
|
@ -25,6 +25,9 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="app"></div>
|
||||
<div
|
||||
class="app"
|
||||
tabindex="0"
|
||||
></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -35,6 +35,7 @@ room.on('entityAdded', (entity) => {
|
|||
}
|
||||
}
|
||||
});
|
||||
const appNode = document.querySelector('.app');
|
||||
// Accept input.
|
||||
const actionRegistry = new ActionRegistry();
|
||||
actionRegistry.mapKeysToActions({
|
||||
|
@ -43,12 +44,11 @@ actionRegistry.mapKeysToActions({
|
|||
's': 'MoveDown',
|
||||
'd': 'MoveRight',
|
||||
});
|
||||
actionRegistry.listen();
|
||||
actionRegistry.listen(appNode);
|
||||
let actionState = actionRegistry.state();
|
||||
// Create the socket connection.
|
||||
const socket = createClient(window.location.href);
|
||||
// Create the graphics canvas.
|
||||
const appNode = document.querySelector('.app');
|
||||
appNode.appendChild(renderer.element);
|
||||
// Input messages.
|
||||
const messageHandle = setInterval(() => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user