将触摸事件分配给画布内的元素 - iPad

问题描述:

我正在为iPad创建一个Web应用程序,并且正在尝试为画布内的元素分配触摸事件。我有这样设置:将触摸事件分配给画布内的元素 - iPad

 
function initialize() { 
    touch_element = new Image(); 
    touch_element.src = 'img/image.png' 
    touch_element.onload = function(){ 
     canvas.drawImage(football, 50, 50, 184, 120); 
     touch_element.addEventListener('touchstart', touch_start, false); 
     touch_element.addEventListener('touchmove', touch_move, false); 
     touch_element.addEventListener('touchend', touch_end, false); 
    } 
} 

我没有收到任何错误返回和图像加载就好。唯一的事情是触摸事件不会触发。在画布中可以做到这一点吗?

您无法将触摸事件分配给image对象。唯一有效的属性是 onerroronload,src,validate

相关线程:Bind event to shape on canvas