touch support

This commit is contained in:
Spmario233 2023-09-26 23:23:48 +08:00
parent f26456e61b
commit 04c17e6f88
1 changed files with 4 additions and 2 deletions

View File

@ -6951,7 +6951,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
UI.draw(); UI.draw();
} }
canvas.addEventListener("click", () => { const click = function(){
switch (state.curr) { switch (state.curr) {
case state.getReady: case state.getReady:
state.curr = state.Play; state.curr = state.Play;
@ -6961,7 +6961,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
bird.flap(); bird.flap();
break; break;
} }
}); };
const switchToAuto = function(){ const switchToAuto = function(){
event._result={ event._result={
bool:true, bool:true,
@ -6973,12 +6973,14 @@ game.import('character',function(lib,game,ui,get,ai,_status){
_status.imchoosing=false; _status.imchoosing=false;
frames=-1; frames=-1;
clearInterval(gameLoop); clearInterval(gameLoop);
document.removeEventListener(lib.config.touchscreen?'touchstart':'mousedown',click);
} }
dialog.open(); dialog.open();
game.pause(); game.pause();
game.countChoose(); game.countChoose();
document.addEventListener(lib.config.touchscreen?'touchstart':'mousedown',click);
setInterval(gameLoop, 10); setInterval(gameLoop, 10);
window.requestAnimationFrame(gameRender); window.requestAnimationFrame(gameRender);
}, },