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:

  1. By calling jQuery.animate () with increasing time.
  2. 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:

    getMouseXYUp (e) {$ ("body"). Die ('mousemove'); H = (document.height - e.pageY + 17); left = id - 1; true = id + 1; settimeout ("leftbyte ()", 100); SetTimeout ("moveright ()", 100); return true} function laddabyte () {if (left> = 0) {$ ( "# Div" + left) .animate ({'height': h}, 400); left--; settimeout ("running The problem is that you are "left" (50);}}

"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

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -