Hello,

I am messing around with an icon i placed on the screen. I have it starting at the exact middle of the screen, and what I want it to do is when I place my finger on a certain location, it will travel to that spot and stop.

This was my thought process going into this...

We have the starting position, (origX, origY)

We have the destination, (destX, destY)

And we have the offset, will get added onto the objects position on each loop through, (xOff, yOff)

What I did with these two is as follows

calculate the gap between the two X's and the two Y's

gapX = Math.abs(origX - destX);

gapY = MAth.abs(origY - destY);

If (gapX > gapY){

xOff = 1;

yOff = gapY / gapX;

}else{

xOff = gapX / gapY;

yOff = 1

}

And then finally I am just checking if the offsets need to be negative and multiplying times -1 if needbe.

This kinda works. What I would like from anyone here is possible some links to some articles on doing things like this. I am assuming there is a better way than what I have attempted. Any help would be appreciated, thank you for your time.

-Nick