开发者

Return object to original position on TouchesEnded?

开发者 https://www.devze.com 2023-04-11 01:26 出处:网络
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 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.

  1. should this be implemented in the TouchesEnded?
  2. 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];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号