Question

I am trying to do a very basic thing but I am new to this. Basically I have a screen with a 3 objects that can move around, I have implemented a method which I call when TouchesMoved happens - if object X moves over main object the object X will be hidden.

What I want to do is when the object Y is released over the main object it will return to the position it was moved from.

  1. should this be implemented in the TouchesEnded?
  2. what would the method look like?

Any help would be very appreciated.

Was it helpful?

Solution

All you'd have to do here, is remember the object position in touchesBegan: and then restore the object in touchesEnded:

If you're only accepting single touches, then you can use something like this in the touchesBegan / touchesEnded methods to grab the touch...

CGPoint location = [[touches anyObject] locationInView:self];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top