+ 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.
3rd Jun 2022, 12:54 AM
Simon Sauter
Simon Sauter - avatar
+ 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.
2nd Jun 2022, 9:18 PM
Simon Sauter
Simon Sauter - avatar
+ 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.
2nd Jun 2022, 9:22 PM
Simon Sauter
Simon Sauter - avatar
0
Why don't you just use the click event instead of mouse over? You can attach multiple function to an element/ event
2nd Jun 2022, 9:22 PM
Lisa
Lisa - avatar
0
You could use click events for both. Just make sure that you add clicker() before move() to the button
2nd Jun 2022, 9:26 PM
Lisa
Lisa - avatar
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?
2nd Jun 2022, 10:19 PM
Lisa
Lisa - avatar
0
It does move. But just once at the start.
2nd Jun 2022, 11:18 PM
Simon Sauter
Simon Sauter - avatar
0
Use a loop?
2nd Jun 2022, 11:20 PM
Simon Sauter
Simon Sauter - avatar
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.
2nd Jun 2022, 11:25 PM
Simon Sauter
Simon Sauter - avatar
0
The original code interacts differently in a web browser opposed to this app. Have you tried it on desktop? To see the differences?
2nd Jun 2022, 11:37 PM
Chris Coder
Chris Coder - avatar
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);
3rd Jun 2022, 12:39 AM
Simon Sauter
Simon Sauter - avatar
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.
3rd Jun 2022, 1:24 AM
Bob_Li
Bob_Li - avatar
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.
3rd Jun 2022, 1:35 AM
Bob_Li
Bob_Li - avatar