+ 3
You put the setInterval line inside the definition of the move function. Move it outside of it and remove the extra call to move that comes directly after and it works.
+ 1
Isn't it by design that you can't click the button? The moment the mouse cursor moves over the button the button jumps away, so of course you can't click it.
However, on mobile, sometimes the button stops moving around and when that happens you can click it and the counter works.
+ 1
It depends on what your goal is. But if you want people to be able to click the button it can't move away before they have the chance to click it.
0
Why don't you just use the click event instead of mouse over?
You can attach multiple function to an element/ event
0
You could use click events for both. Just make sure that you add clicker() before move() to the button
0
In case you are trying to do a game of catching the button, shouldn't the moving be primarily independent of the user's response? Like the button changing its position at random intervals when the player doesn't catch it?
0
It does move. But just once at the start.
0
Use a loop?
0
Your condition makes no sense. I'd try using an infinite loop using true as condition. But I don't have much experience with Javascript, so I'm not sure if that will work.
0
The original code interacts differently in a web browser opposed to this app. Have you tried it on desktop? To see the differences?
0
In the current version of "Click the Button Game" remove the move function from line 37. And use this line to keep the button moving (I think in an earlier version you had it right except that you had "move" and "1000" in the wrong order):
setInterval(move,1000);
0
Your Mom
what Simon Sauter said.
put the setInterval outside the move function AND remove the move().
Also, you don't need to randomize four parameters.
top, left or bottom,left is enough to move the button in 2 directions.
0
not the function move.
The extra call to the function under the function definition.
function move(){
.......
}
move() <-- This oneđ
setInterval(....
It works without that line for me.