-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
canvas sizing and controls outside of the canvas #85
Comments
I think I might've (albeit hackily) solved part 2 of my own questions: i noticed that i need both function triggerKeypress(key) {
const body = document.body;
body.dispatchEvent(new KeyboardEvent("keydown", { key }));
setTimeout(() => {
body.dispatchEvent(new KeyboardEvent("keyup", { key }));
}, 25); // need this so host can trigger properly
}
const button = document.querySelector("button");
button.addEventListener("click", () => {
triggerKeypress("ArrowRight");
}); of course, feel free to suggest something cleaner |
It'd be nice if we could extend let holdingButton = false;
$("#button").addEventListener("touchstart", () => {
holdingButton = true;
});
$("#button").addEventListener("touchend", () => {
holdingButton = false;
});
//do similar things for mousedown/mouseup and Enter/spacebar with keydown/keyup
// ...
tick(playerInputs) {
if (holdingButton) {
// trigger action that the button is firing
}
} |
any help? i'm not sure why clicking the buttons works for player 1 but not for player 2 in my demo: https://github.com/hchiam/learning-webrtc/tree/08e760cb8e0d36fb2a4073437800178558f1208a/netplay-demo |
https://hchiam-netplay-demo-browser-buttons.surge.sh/ |
Do we have any info on the first part of your question? Game.canvasSize = { width: 600, height: 400 }; and console:
|
i'd like to create a page with netplayjs displaying its canvas, but with buttons and text outside of the canvas that i can control with regular html and js - 2 questions:
The text was updated successfully, but these errors were encountered: