我正在开发一个html5画布游戏,但我不知道如何处理触摸事件.当用户触摸屏幕并拖动时,浏览器将滚动页面.我想阻止它,并触摸开始,并触摸结束位置.可能吗?
提前致谢
我正在使用easlejs + phonegap处理HTML5游戏,并且遇到了每次在画布上单击/触摸/ mousedown时屏幕闪烁的问题.
下面是我为测试问题而创建的非常简单的代码,看它是否与easlejs相关.从代码中可以看出,它与easlejs无关,只是一个html5/phonegap问题.
你可以看到我也尝试了没有选择的CSS样式,没有运气.

<!doctype html>
<html>
<head>
<title></title>
<style type="text/css">
#canvas
{
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
}
</style>
</head>
<body>
<canvas id="canvas" width="320" height="480"></canvas>
<script type="text/javascript">
var canvas = document.getElementById("canvas");
canvas.addEventListener("mousedown", function(e)
{
var ctx = canvas.getContext("2d");
var x = Math.random() * 320;
var y = Math.random() * 480;
var w = Math.random() * 100;
var h = Math.random() * 100;
ctx.fillStyle = "#FF0000";
ctx.fillRect(x,y,w,h);
}, false);
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)