0

I have implemented the algorithm, but what I am facing is how can I check constantly whether the element has hit other elements.

Example:

div id='water' when hits div id='orange' should alert , should I use jQuery setInterval :s or is there any other way to keep the function live ?

4

1 回答 1

0

您应该使用setInterval()。这是一个小样本。

$(document).ready(function() {
    // Checks collisions every second
    setInterval(function(){checkCollisions()},1000);
});


function checkCollisions() {
    // Do your checks
}
于 2012-07-07T17:42:09.143 回答