0
I would like to know how to stop a pixel moving in a specific direction, is it possible?
My question is I'm trying to stop a pixel from moving a certain direction by recording the current position of the pixel, how can this be done? Any suggestions are welcome.
5 Respuestas
+ 2
dynk
here is my take on your code.
https://sololearn.com/compiler-playground/Wu4cMvnpYnqo/?ref=app
+ 1
Do you have an example code?
https://sololearn.com/compiler-playground/Wek0V1MyIR2r/?ref=app
+ 1
+ 1
Do you mean that when you hit the stop button, you want the square to stay still?
Or when the square gets to the end of the container?
The first one:
You'd have to stop the animate variable from adding the position on.
The second one:
Before you update the move, check if the boundary has been "hit".
+ 1
perhaps use clearInterval(animate) for the stop button?
Btw, you can use the <button></button> element instead of input type button or submit