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 开发者_StackOverflow中文版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.
- should this be implemented in the TouchesEnded?
- what would the method look like?
Any help would be very appreciated.
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];
精彩评论