javascript - calling setTimeout again stops first instance -
I have a small game that I wrote in javascript, from which side you click, create a wave Does. I found two ways to move "wave" on the screen:
- By calling jQuery.animate () with increasing time.
- Call Set-Timeout I have the problem that I want to behave 2 (the column increases with all the offset time at the same speed), but with the verb of 1 ("wive" right now) Up to the second demo, if you click again before the "wave" ends, then it immediately clears the setmemeate and starts it again again. I might be able to pile them like the first example
Give you the code Can see the source of any one of those pages (methods MOUSEXYUp and getMouseXYDown).
The basic essence of what I am doing in the second demo is found in these two functions Is:
"And" OK "as soon as the other mouse click is close to what it's looking for you?
getMouseXYUp function (e) {$ ("body") Die ('mousemove'); Var h = (document.height - e.pageY + 17); Var left = id-1; Var correct = id + 1; SetTimeout (Left (left);}, 100); SetTimeout (function () {moveright (right, h);}, 100); return true;} ... function slideby (left, h) {If (left> = 0) {$ ("# div" + left). Sammet ({'height': h}, 400); left--; SetTimeout (function () (move left, h) (; '' Height '': H}, 400); right; (right), if the right (
Comments
Post a Comment