我设置了以下页面,用于检测用户touchstart,touchmoves和touchends时的坐标。我正在尝试构建某种类型的游戏,在这种游戏中,用户必须为某些代码绘制星形才能执行。我怎样才能检测到什么时候已经传递了11个点来执行某些代码:
这是迄今为止的代码:
touchMe[0].ontouchstart = function(e) {
log.html("Touch Start");
var touche= e.touches[0];
//instead of e.clientX, in touch event we have to acess like this e.touches[0].clientX.
log.append("X :" + touche.clientX + "Y :" +touche.clientY);
log.append("</br>");
}
touchMe[0].ontouchmove = function(e) {
log.html("Touch Move");
var touche= e.touches[0];
//instead of e.clientX, in touch event we have to acess like this e.touches[0].clientX.
log.append("X :" + touche.clientX + "Y :" +touche.clientY);
log.append("</br>");
}
touchMe.bind("touchend", function(e) {
log.html("LOG");
});
样本
http://machinas.com/wip/esprit/Projects-2014/xmas-game-2014/interaction5/