这是我的游戏 -我的游戏
问题:
当我在 Google Chrome 开发人员工具中检查游戏并单击(轻敲)画布(或按钮)时,它会出现小延迟,然后汽车向左或向右移动。我该如何解决这个问题?
(我想为移动设备制作游戏)
我试过了:
<meta name="viewport" content="width=device-width, user-scalable=no">
我正在使用touchstart
事件。但是还是什么都没有……
编辑:
好的,我尝试了 FastClick,但它不起作用。
<script type="application/javascript" src="js/fastclick.js"></script>
<script type="application/javascript">
window.addEventListener('load', function() {
FastClick.attach(document.body);
document.getElementById("goleft").addEventListener('touchstart', function(){
superCar.speedX = -40;
}, true)
document.getElementById("goleft").addEventListener('touchend', function(){
superCar.speedX = 0;
}, true)
document.getElementById("goright").addEventListener('touchstart', function(){
superCar.speedX = 40;
}, true)
document.getElementById("goright").addEventListener('touchend', function(){
superCar.speedX = 0;
}, true)
}, true)
</script>
触摸事件现在在<head>