I am coding a javascript moving ball game. I want to receive a warning message when the user manages to click on a moving ball. It works right now, but this event does not shoot every time ... It seems that the ball is moving too fast for the js engine to notice that the ball really hit. I am testing Firefox 18, Windows 7 on a 5 year old processor ...
Here are a few bits of my code:
myBall = document.getElementById("myBall"); function move(){ myLeft += 20; myBall.style.left = myLeft + "px"; } myTimer = window.setInterval(move, 10); ... myBall.addEventListener("click", function(){alert("win")});
Is there a way to set a click event listener on a small moving target that will behave more accurately? Will jQuery have any meaning here? Thanks.
source share