So, as soon as image1 starts to move you want it to "snap" to the other point? Or do you just want it's movement restricted to the y-axis between the two endpoints? If the latter, just add some logic to only recenter the image if the x location falls between the two endpoints.i want to be able to move image1 between the 2 points
Then add logic that if image1 is at one point, recenter at the other point. And vice-versa. Something like this perhaps:i want image1 movement to be restricted between the 2 points how can it be done i have been stuckon this for sometime now and cant find anything online
if ([touch view] == image1) {
CGPoint newLocation;
if (image1.center.x == x1) {
newLocation = CGPointMake(x2,280);
} else {
newLocation = CGPointMake(x1,280);
}
image1.center = newLocation;
}
if ([touch view] == image1) {
CGPoint newLocation;
if (image1.center.x >= x1 && image1.center.x <= x2) {
...
image1.center = newLocation;
}
}
Confused? Why? Help us to understand what's confusing you.it would seem that i am not smart enough, confused actually.
Oops, what I meant was:if ([touch view] == image1) {
CGPoint newLocation;
if (image1.center.x >= 140 && image1.center.x <= 340) {
CGPoint newLocation = CGPointMake(touchLocation.x, 280);
image1.center = newLocation;
}
}
this allows me to move it to one of the points but when it hits a point it is stuck there.
i also get a warning that newLocation is a unused variable
if (touchLocation.x >= 140 && touchLocation.x <= 340)
[CODE]...[/CODE]
You're welcome. You understand what it's doing, right?it works, thank you for your help![]()