Sprite move to a direction

Hello I am triying to move a sprite to one point to other and when it reach the point this has to stop.

These are my block, I can do the movement but I can´t do the sprite stop when this reach the point. Any sugestion?

You need to define the edges of your screen as the maximal XY value in your clock component part.

The problem is that you are asking if the sprite reached the exact x,y point you touched in the canvas. That may happen or may not. Because the sprite doesn’t move exactly 1 pixel in each step.
Example: You touch 200,300. The sprite is in 10,10. If the sprite moves 3 pixels each time, you will never be EXACTLY in 200,300. You may be close to that point but your if x=xcamino and y=ycamino will never be true.

I don´t get it, can you show me with blocks?

That’s not the problem.

I can understand, so maybe if the speed is 2 maybe work or doing some formula that stop close to the position, right?

1 Like

That’s right. You need to come up with a way to be sure it will work every time.
In your case I would do this

if x > xcamino -10
and
x < xcamino + 10
and
y > ycamino -10
and
y < ycamino + 10

then stop

That way you are giving it 20 pixels for approximation. May be you can lower that 10 to a 5 or 3. Probably you can use the sprite speed for that number too.
Test it.

The only problem is most of the time it will never be the exact x,y point you touched. It will be very close but not exactly.