나는이 사이트에 처음이고 이것은 내가 여기서 묻는 첫 번째 질문이다. 간단한 pls가 나를 용서한다면 .. 나는 하나의 배경 이미지를 그렸다. 이것에 나는 drawImage () 메소드를 사용하여 5 개의 작은 작은 이미지를 그리고있다. 작은 이미지를 터치하면 사라지거나 하나의 경고 상자가 나타나야하지만 지금까지 ontouch 이벤트가 발생하지 않고 ontouch 이벤트를 검색했지만 사용하지 않았습니다. HTML의 img 태그를 통해 이미지를 그리고 싶지 않습니다. 다음은 내 코드 세그먼트입니다.
var car = new Image();
car.src = "img/car.jpg";
car.onload = function() {
imgLoaded = true;
}
if (imgLoaded = true) {
drawBackgroundImg();
drawCarImg();
}
function drawCarImg() {
if (i == 0) {
x1 = Math.floor((Math.random() * 501));
y1 = Math.floor((Math.random() * 301));
cxt.save();
cxt.drawImage(car, x1, y1, car.width, car.height);
cxt.restore();
}
}
car.on('touchstart', function() {
alert("T");
});
Here is my HTML code
<!DOCTYPE html>
<body>
<div id="container" onclick="void(0)">
<canvas id="can"> </canvas>
</div>
<div id="btn">
<input type="image" id="zoomIn" src="img/up.png" onclick="zoomIn()" />
<input type="image" id="zoomOut" src="img/down.png"
onclick="zoomOut()" />
</div>
<div id="score">
<p id="scoreCount">
<b></b>
</p>
</div>
</body>
</html>
아무도 해결책을 얻도록 도와 줄 수 있습니까? 참고 : 브라우저가 아닌 Phonegap에서이 코드를 실행하고 있습니다.
나는 대답을 찾았고, 보이지 않는 div를 만들고 절대 위치에 이미지를 배치하고 이미지의 ID를 사용하고 touchstart 이벤트를 트리거합니다. 위에서 언급 한 예
$('#id').on('touchmove',function(){
alert("T");
});
$('#id').on('click',function(){
alert("T");
});
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다