mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-08-02 06:43:21 +00:00
Fix player select with touch controls (#325)
This commit is contained in:
parent
875673c661
commit
2378288a5b
3 changed files with 8 additions and 1 deletions
3
web/js/controller.js
vendored
3
web/js/controller.js
vendored
|
|
@ -406,6 +406,9 @@
|
|||
event.sub(GAME_ROOM_AVAILABLE, onGameRoomAvailable, 2);
|
||||
event.sub(GAME_SAVED, () => message.show('Saved'));
|
||||
event.sub(GAME_LOADED, () => message.show('Loaded'));
|
||||
event.sub(GAME_PLAYER_IDX_CHANGE, data => {
|
||||
updatePlayerIndex(data.index);
|
||||
});
|
||||
event.sub(GAME_PLAYER_IDX, idx => {
|
||||
if (!isNaN(+idx)) message.show(+idx + 1);
|
||||
});
|
||||
|
|
|
|||
2
web/js/event/event.js
vendored
2
web/js/event/event.js
vendored
|
|
@ -62,6 +62,8 @@ const PING_RESPONSE = 'pingResponse';
|
|||
const GAME_ROOM_AVAILABLE = 'gameRoomAvailable';
|
||||
const GAME_SAVED = 'gameSaved';
|
||||
const GAME_LOADED = 'gameLoaded';
|
||||
// used to transfer the index value between touch and controller
|
||||
const GAME_PLAYER_IDX_CHANGE = 'gamePlayerIndexChange';
|
||||
const GAME_PLAYER_IDX = 'gamePlayerIndex';
|
||||
|
||||
const CONNECTION_READY = 'connectionReady';
|
||||
|
|
|
|||
4
web/js/input/touch.js
vendored
4
web/js/input/touch.js
vendored
|
|
@ -165,8 +165,9 @@ const touch = (() => {
|
|||
}, 30);
|
||||
}
|
||||
|
||||
// !to rewrite slider completely
|
||||
function handlePlayerSlider() {
|
||||
socket.updatePlayerIndex(this.value - 1);
|
||||
event.pub(GAME_PLAYER_IDX_CHANGE, {index: +this.value - 1})
|
||||
}
|
||||
|
||||
// Touch menu
|
||||
|
|
@ -279,6 +280,7 @@ const touch = (() => {
|
|||
playerSlider.addEventListener('oninput', handlePlayerSlider);
|
||||
playerSlider.addEventListener('onchange', handlePlayerSlider);
|
||||
playerSlider.addEventListener('mouseup', handlePlayerSlider);
|
||||
playerSlider.addEventListener('touchend', handlePlayerSlider);
|
||||
|
||||
// Bind events for menu
|
||||
// TODO change this flow
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue