I have two subviews sv1 and sv2 that I've animated by setting their center properties inside of an animation block. This animation code is in sv1.m and sv2.m. It all works just fine: they both move smoothly around in the superview by choosing new centre points in a continuous loop. It looks quite cute, really.

What I want to do now is detect when they come within a certain distance of one another as they're moving. But when I do this to move them:

        sv1.center = p1;
        sv2.center = p2;

their center properties are set immediately to the new values: i.e. they can't be read to find the intermediate positions. So I can't use these properties to find out if their centres come within a given distance of one another.

I've thought of some possible approaches:

1. Having the superview controller calculate whether the lines between the animation start and finish points intersect, and whether sv1 and sv2 will be at the intersection at the same time.

2. Breaking up the straight line moves into much smaller segments and having the center properties set successively to those.

3. Having the superview controller handle the animation and somehow keep track of the subview's relative distances.

4. Using keyframe animation instead.

#1 seems rather complicated. #2 seems likely to lead to a choppy animation, and would rule out using the speed-up-then-slow-down animation mode. #3 would involve throwing out a lot of the code I've written so far. And I don't yet have a clue whether #4 is plausible, not having used keyframe animation before.

If there are any other suggestions, I'd be grateful to hear them!

dkj
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to