I have an object that the user has to drag around the screen. This is a regular UIImageView. Currently, the image can be dragged around but when you release it, it stops where your finger lifted the image. What I want is to create momentum, so I can give an impulse to the image and it scrolls until it bounces the screen edge.
I don’t want nothing very complex like adding physics libraries and stuff like that. I want to keep it as minimum as possible.
How do I do that? Can you guys point me to some tutorial or in the right direction?
thanks.
Well one way of doing this without using any physics library is this:
First in your class create 4 instance variables like this:
Than in your
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)eventmethod have this code:For
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)eventdo this:Now for
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)eventtry this:Please let me know if this makes sense and/or works for you. Cheers!